[med-svn] [Git][med-team/edflib][upstream] New upstream version 1.20

Nilesh Patra (@nilesh) gitlab at salsa.debian.org
Tue Nov 9 18:56:19 GMT 2021



Nilesh Patra pushed to branch upstream at Debian Med / edflib


Commits:
d0c04ab8 by Nilesh Patra at 2021-11-10T00:06:36+05:30
New upstream version 1.20
- - - - -


4 changed files:

- Makefile
- edflib.c
- edflib.h
- unittest/unittest.c


Changes:

=====================================
Makefile
=====================================
@@ -1,5 +1,5 @@
 CC = gcc
-CFLAGS = -O3 -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE
+CFLAGS = -O2 -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE
 LDLIBS = -lm
 
 programs = sine_generator sweep_generator test_edflib test_generator


=====================================
edflib.c
=====================================
@@ -31,21 +31,13 @@
 *****************************************************************************
 */
 
-
-
-
 /* compile with options "-D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" */
 
-
-
-
 #include "edflib.h"
 
-
-#define EDFLIB_VERSION  (119)
+#define EDFLIB_VERSION  (120)
 #define EDFLIB_MAXFILES  (64)
 
-
 #if defined(__APPLE__) || defined(__MACH__) || defined(__APPLE_CC__) || defined(__HAIKU__)
 
 #define fopeno fopen
@@ -58,7 +50,6 @@
 
 #endif
 
-
 #ifdef _WIN32
 
 #ifndef __MINGW32__
@@ -76,8 +67,6 @@
 
 #endif
 
-
-
 /* max size of annotationtext */
 #define EDFLIB_WRITE_MAX_ANNOTATION_LEN  (40)
 
@@ -89,7 +78,6 @@
 
 #define EDFLIB_ANNOT_MEMBLOCKSZ  (1000)
 
-
 struct edfparamblock{
         char   label[17];
         char   transducer[81];
@@ -158,14 +146,12 @@ struct edfhdrblock{
         struct edfparamblock *edfparam;
       };
 
-
 static struct edf_annotationblock{
         long long onset;
         char duration[16];
         char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1];
        } *annotationslist[EDFLIB_MAXFILES];
 
-
 static struct edf_write_annotationblock{
         long long onset;
         long long duration;
@@ -176,7 +162,6 @@ static int edf_files_open=0;
 
 static struct edfhdrblock *hdrlist[EDFLIB_MAXFILES];
 
-
 static struct edfhdrblock * edflib_check_edf_file(FILE *, int *);
 static int edflib_is_integer_number(char *);
 static int edflib_is_number(char *);
@@ -203,8 +188,6 @@ static int edflib_strlcpy(char *, const char *, int);
 static int edflib_strlcat(char *, const char *, int);
 
 
-
-
 int edflib_is_file_used(const char *path)
 {
   int i;
@@ -985,6 +968,15 @@ int edfread_physical_samples(int handle, int edfsignal, int n, double *buf)
       }
       var.four[1] = tmp;
 
+      if(var.two_signed[0] > hdr->edfparam[channel].dig_max)
+      {
+        var.two_signed[0] = hdr->edfparam[channel].dig_max;
+      }
+      else if(var.two_signed[0] < hdr->edfparam[channel].dig_min)
+        {
+          var.two_signed[0] = hdr->edfparam[channel].dig_min;
+        }
+
       buf[i] = phys_bitvalue * (phys_offset + (double)var.two_signed[0]);
 
       sample_pntr++;
@@ -1021,6 +1013,15 @@ int edfread_physical_samples(int handle, int edfsignal, int n, double *buf)
         var.four[3] = 0x00;
       }
 
+      if(var.one_signed > hdr->edfparam[channel].dig_max)
+      {
+        var.one_signed = hdr->edfparam[channel].dig_max;
+      }
+      else if(var.one_signed < hdr->edfparam[channel].dig_min)
+        {
+          var.one_signed = hdr->edfparam[channel].dig_min;
+        }
+
       buf[i] = phys_bitvalue * (phys_offset + (double)var.one_signed);
 
       sample_pntr++;
@@ -1165,6 +1166,15 @@ int edfread_digital_samples(int handle, int edfsignal, int n, int *buf)
       }
       var.four[1] = tmp;
 
+      if(var.two_signed[0] > hdr->edfparam[channel].dig_max)
+      {
+        var.two_signed[0] = hdr->edfparam[channel].dig_max;
+      }
+      else if(var.two_signed[0] < hdr->edfparam[channel].dig_min)
+        {
+          var.two_signed[0] = hdr->edfparam[channel].dig_min;
+        }
+
       buf[i] = var.two_signed[0];
 
       sample_pntr++;
@@ -1201,6 +1211,15 @@ int edfread_digital_samples(int handle, int edfsignal, int n, int *buf)
         var.four[3] = 0x00;
       }
 
+      if(var.one_signed > hdr->edfparam[channel].dig_max)
+      {
+        var.one_signed = hdr->edfparam[channel].dig_max;
+      }
+      else if(var.one_signed < hdr->edfparam[channel].dig_min)
+        {
+          var.one_signed = hdr->edfparam[channel].dig_min;
+        }
+
       buf[i] = var.one_signed;
 
       sample_pntr++;
@@ -3378,8 +3397,12 @@ static long long edflib_get_long_time(char *str)
 
 static void edflib_latin1_to_ascii(char *str, int len)
 {
+  /* ISO 8859-1 except for characters 0x80 to 0x9f which are taken from the extension CP-1252 */
+
   int i, value;
 
+  const char conv_table[]=".E.,F\".++^.S<E.Z..`\'\"\".--~.s>e.zY.i....|....<...-....\'u.....>...?AAAAAAECEEEEIIIIDNOOOOOxOUUUUYtsaaaaaaeceeeeiiiidnooooo:0uuuuyty";
+
   for(i=0; i<len; i++)
   {
     value = *((unsigned char *)(str + i));
@@ -3389,200 +3412,14 @@ static void edflib_latin1_to_ascii(char *str, int len)
       continue;
     }
 
-    switch(value)
+    if(value < 32)
     {
-      case 128 : str[i] = 'E';  break;
-
-      case 130 : str[i] = ',';  break;
-
-      case 131 : str[i] = 'F';  break;
-
-      case 132 : str[i] = '\"';  break;
-
-      case 133 : str[i] = '.';  break;
-
-      case 134 : str[i] = '+';  break;
-
-      case 135 : str[i] = '+';  break;
-
-      case 136 : str[i] = '^';  break;
-
-      case 137 : str[i] = 'm';  break;
-
-      case 138 : str[i] = 'S';  break;
-
-      case 139 : str[i] = '<';  break;
-
-      case 140 : str[i] = 'E';  break;
-
-      case 142 : str[i] = 'Z';  break;
-
-      case 145 : str[i] = '`';  break;
-
-      case 146 : str[i] = '\'';  break;
-
-      case 147 : str[i] = '\"';  break;
-
-      case 148 : str[i] = '\"';  break;
-
-      case 149 : str[i] = '.';  break;
-
-      case 150 : str[i] = '-';  break;
-
-      case 151 : str[i] = '-';  break;
-
-      case 152 : str[i] = '~';  break;
-
-      case 154 : str[i] = 's';  break;
-
-      case 155 : str[i] = '>';  break;
-
-      case 156 : str[i] = 'e';  break;
-
-      case 158 : str[i] = 'z';  break;
-
-      case 159 : str[i] = 'Y';  break;
-
-      case 171 : str[i] = '<';  break;
-
-      case 180 : str[i] = '\'';  break;
-
-      case 181 : str[i] = 'u';  break;
-
-      case 187 : str[i] = '>';  break;
-
-      case 191 : str[i] = '\?';  break;
-
-      case 192 : str[i] = 'A';  break;
-
-      case 193 : str[i] = 'A';  break;
-
-      case 194 : str[i] = 'A';  break;
-
-      case 195 : str[i] = 'A';  break;
-
-      case 196 : str[i] = 'A';  break;
-
-      case 197 : str[i] = 'A';  break;
-
-      case 198 : str[i] = 'E';  break;
-
-      case 199 : str[i] = 'C';  break;
-
-      case 200 : str[i] = 'E';  break;
-
-      case 201 : str[i] = 'E';  break;
-
-      case 202 : str[i] = 'E';  break;
-
-      case 203 : str[i] = 'E';  break;
-
-      case 204 : str[i] = 'I';  break;
-
-      case 205 : str[i] = 'I';  break;
-
-      case 206 : str[i] = 'I';  break;
-
-      case 207 : str[i] = 'I';  break;
-
-      case 208 : str[i] = 'D';  break;
-
-      case 209 : str[i] = 'N';  break;
-
-      case 210 : str[i] = 'O';  break;
-
-      case 211 : str[i] = 'O';  break;
-
-      case 212 : str[i] = 'O';  break;
-
-      case 213 : str[i] = 'O';  break;
-
-      case 214 : str[i] = 'O';  break;
-
-      case 215 : str[i] = 'x';  break;
-
-      case 216 : str[i] = 'O';  break;
-
-      case 217 : str[i] = 'U';  break;
+      str[i] = '.';
 
-      case 218 : str[i] = 'U';  break;
-
-      case 219 : str[i] = 'U';  break;
-
-      case 220 : str[i] = 'U';  break;
-
-      case 221 : str[i] = 'Y';  break;
-
-      case 222 : str[i] = 'I';  break;
-
-      case 223 : str[i] = 's';  break;
-
-      case 224 : str[i] = 'a';  break;
-
-      case 225 : str[i] = 'a';  break;
-
-      case 226 : str[i] = 'a';  break;
-
-      case 227 : str[i] = 'a';  break;
-
-      case 228 : str[i] = 'a';  break;
-
-      case 229 : str[i] = 'a';  break;
-
-      case 230 : str[i] = 'e';  break;
-
-      case 231 : str[i] = 'c';  break;
-
-      case 232 : str[i] = 'e';  break;
-
-      case 233 : str[i] = 'e';  break;
-
-      case 234 : str[i] = 'e';  break;
-
-      case 235 : str[i] = 'e';  break;
-
-      case 236 : str[i] = 'i';  break;
-
-      case 237 : str[i] = 'i';  break;
-
-      case 238 : str[i] = 'i';  break;
-
-      case 239 : str[i] = 'i';  break;
-
-      case 240 : str[i] = 'd';  break;
-
-      case 241 : str[i] = 'n';  break;
-
-      case 242 : str[i] = 'o';  break;
-
-      case 243 : str[i] = 'o';  break;
-
-      case 244 : str[i] = 'o';  break;
-
-      case 245 : str[i] = 'o';  break;
-
-      case 246 : str[i] = 'o';  break;
-
-      case 247 : str[i] = '-';  break;
-
-      case 248 : str[i] = '0';  break;
-
-      case 249 : str[i] = 'u';  break;
-
-      case 250 : str[i] = 'u';  break;
-
-      case 251 : str[i] = 'u';  break;
-
-      case 252 : str[i] = 'u';  break;
-
-      case 253 : str[i] = 'y';  break;
-
-      case 254 : str[i] = 't';  break;
-
-      case 255 : str[i] = 'y';  break;
-
-      default  : str[i] = ' ';  break;
+      continue;
     }
+
+    str[i] = conv_table[value - 127];
   }
 }
 
@@ -3639,6 +3476,86 @@ static void edflib_latin12utf8(char *latin1_str, int len)
 }
 
 
+int edfopen_file_writeonly_with_params(const char *path, int filetype, int number_of_signals, int samplefrequency, double phys_max_min, const char *phys_dim)
+{
+  int i, handle;
+
+  char str[32]="";
+
+  handle = edfopen_file_writeonly(path, filetype, number_of_signals);
+  if(handle < 0)
+  {
+    return handle;
+  }
+
+  for(i=0; i<number_of_signals; i++)
+  {
+    if(edf_set_samplefrequency(handle, i, samplefrequency))
+    {
+      edfclose_file(handle);
+      return -1;
+    }
+
+    if(edf_set_physical_maximum(handle, i, phys_max_min))
+    {
+      edfclose_file(handle);
+      return -1;
+    }
+
+    if(edf_set_physical_minimum(handle, i, -phys_max_min))
+    {
+      edfclose_file(handle);
+      return -1;
+    }
+
+    if(edf_set_physical_dimension(handle, i, phys_dim))
+    {
+      edfclose_file(handle);
+      return -1;
+    }
+
+    snprintf(str, 32, "chan. %i", i + 1);
+
+    if(edf_set_label(handle, i, str))
+    {
+      edfclose_file(handle);
+      return -1;
+    }
+
+    if(filetype == EDFLIB_FILETYPE_BDFPLUS)
+    {
+      if(edf_set_digital_maximum(handle, i, 8388607))
+      {
+        edfclose_file(handle);
+        return -1;
+      }
+
+      if(edf_set_digital_minimum(handle, i, -8388608))
+      {
+        edfclose_file(handle);
+        return -1;
+      }
+    }
+    else
+    {
+      if(edf_set_digital_maximum(handle, i, 32767))
+      {
+        edfclose_file(handle);
+        return -1;
+      }
+
+      if(edf_set_digital_minimum(handle, i, -32768))
+      {
+        edfclose_file(handle);
+        return -1;
+      }
+    }
+  }
+
+  return handle;
+}
+
+
 int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals)
 {
   int i, handle;


=====================================
edflib.h
=====================================
@@ -31,23 +31,78 @@
 *****************************************************************************
 */
 
-
+/****************************************************************************
+ *
+ * For more info about the EDF and EDF+ format, visit: http://edfplus.info/specs/
+ *
+ * For more info about the BDF and BDF+ format, visit: http://www.teuniz.net/edfbrowser/bdfplus%20format%20description.html
+ *
+ * note: In EDF, the resolution (or sensitivity) (e.g. uV/bit) and offset are stored using four parameters:
+ * digital maximum and minimum, and physical maximum and minimum.
+ * Here, digital means the raw data coming from a sensor or ADC. Physical means the units like uV.
+ * The resolution in units per least significant bit is calculated as follows:
+ *
+ * units per bit = (physical max - physical min) / (digital max - digital min)
+ *
+ * The digital offset is calculated as follows:
+ *
+ * offset = (physical max / units per bit) - digital max
+ *
+ * For a better explanation about the relation between digital data and physical data,
+ * read the document "Coding Schemes Used with Data Converters" (PDF):
+ *
+ * https://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sbaa042
+ *
+ * note: An EDF file usually contains multiple so-called datarecords. One datarecord usually has a duration of one second (this is the default but it is not mandatory!).
+ * In that case a file with a duration of five minutes contains 300 datarecords. The duration of a datarecord can be freely choosen but, if possible, use values from
+ * 0.1 to 1 second for easier handling. Just make sure that the total size of one datarecord, expressed in bytes, does not exceed 10MByte (15MBytes for BDF(+)).
+ *
+ * The RECOMMENDATION of a maximum datarecordsize of 61440 bytes in the EDF and EDF+ specification was usefull in the time people were still using DOS as their main operating system.
+ * Using DOS and fast (near) pointers (16-bit pointers), the maximum allocatable block of memory was 64KByte.
+ * This is not a concern anymore so the maximum datarecord size now is limited to 10MByte for EDF(+) and 15MByte for BDF(+). This helps to accommodate for higher samplingrates
+ * used by modern Analog to Digital Converters.
+ *
+ * EDF header character encoding: The EDF specification says that only (printable) ASCII characters are allowed.
+ * When writing the header info, EDFlib will assume you are using Latin1 encoding and it will automatically convert
+ * characters with accents, umlauts, tilde, etc. to their "normal" equivalent without the accent/umlaut/tilde/etc.
+ * in order to create a valid EDF file.
+ * The description of an EDF+ annotation on the other hand, is always encoded in UTF-8 (which is foreward compatible with ASCII).
+ *
+ * The samplefrequency of a signal is calculated as follows: sf = (smp_in_datarecord * EDFLIB_TIME_DIMENSION) / datarecord_duration
+ *
+ * Annotation signals
+ * ==================
+ *
+ * EDF+ and BDF+ store the annotations in one or more signals (in order to be backwards compatibel with EDF and BDF).
+ * The numbering of the signals in the file is zero based (starts at 0). Signals used for annotations are skipped by EDFlib.
+ * This means that the annotationsignal(s) in the file are hided.
+ * Use the function edf_get_annotation() to get the annotations.
+ *
+ * So, when a file contains 5 signals and the third signal is an annotations signal, the library will
+ * report that there are only 4 signals in the file.
+ * The library will "map" the signal numbers as follows: 0->0, 1->1, 2->3, 3->4.
+ * This way you don't need to worry about which signals are annotationsignals, the library will take care of it.
+ *
+ * How the library stores time values
+ * ==================================
+ *
+ * To avoid rounding errors, the library stores some timevalues in variables of type long long int.
+ * In order not to lose the subsecond precision, all timevalues are scaled with a scaling factor: 10000000.
+ * This will limit the timeresolution to 100 nanoSeconds. To calculate the amount of seconds, divide
+ * the timevalue by 10000000 or use the macro EDFLIB_TIME_DIMENSION which is declared in edflib.h.
+ * The following variables use this scaling when you open a file in read mode: "file_duration", "starttime_subsecond" and "onset".
+ */
 
 /* compile with options "-D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" */
 
-
-
 #ifndef EDFLIB_INCLUDED
 #define EDFLIB_INCLUDED
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
-
-
 #define EDFLIB_TIME_DIMENSION     (10000000LL)
 #define EDFLIB_MAXSIGNALS                (640)
 #define EDFLIB_MAX_ANNOTATION_LEN        (512)
@@ -56,10 +111,8 @@
 #define EDFSEEK_CUR  (1)
 #define EDFSEEK_END  (2)
 
-
-
-/* the following defines are used in the member "filetype" of the edf_hdr_struct */
-/* and as return value for the function edfopen_file_readonly() */
+/* the following defines are used in the member "filetype" of the edf_hdr_struct
+   and as return value for the function edfopen_file_readonly() */
 #define EDFLIB_FILETYPE_EDF                  (0)
 #define EDFLIB_FILETYPE_EDFPLUS              (1)
 #define EDFLIB_FILETYPE_BDF                  (2)
@@ -94,85 +147,38 @@
 #define EDFLIB_PHYSMIN_IS_PHYSMAX          (-25)
 #define EDFLIB_DATARECORD_SIZE_TOO_BIG     (-26)
 
-
-
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
-
-/* For more info about the EDF and EDF+ format, visit: http://edfplus.info/specs/ */
-
-/* For more info about the BDF and BDF+ format, visit: http://www.teuniz.net/edfbrowser/bdfplus%20format%20description.html */
-
-/*
- * note: In EDF, the sensitivity (e.g. uV/bit) and offset are stored using four parameters:
- * digital maximum and minimum, and physical maximum and minimum.
- * Here, digital means the raw data coming from a sensor or ADC. Physical means the units like uV.
- * The sensitivity in units/bit is calculated as follows:
- *
- * units per bit = (physical max - physical min) / (digital max - digital min)
- *
- * The digital offset is calculated as follows:
- *
- * offset = (physical max / units per bit) - digital max
- *
- * For a better explanation about the relation between digital data and physical data,
- * read the document "Coding Schemes Used with Data Converters" (PDF):
- *
- * http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sbaa042
- *
- * note: An EDF file usually contains multiple so-called datarecords. One datarecord usually has a duration of one second (this is the default but it is not mandatory!).
- * In that case a file with a duration of five minutes contains 300 datarecords. The duration of a datarecord can be freely choosen but, if possible, use values from
- * 0.1 to 1 second for easier handling. Just make sure that the total size of one datarecord, expressed in bytes, does not exceed 10MByte (15MBytes for BDF(+)).
- *
- * The RECOMMENDATION of a maximum datarecordsize of 61440 bytes in the EDF and EDF+ specification was usefull in the time people were still using DOS as their main operating system.
- * Using DOS and fast (near) pointers (16-bit pointers), the maximum allocatable block of memory was 64KByte.
- * This is not a concern anymore so the maximum datarecord size now is limited to 10MByte for EDF(+) and 15MByte for BDF(+). This helps to accommodate for higher samplingrates
- * used by modern Analog to Digital Converters.
- *
- * EDF header character encoding: The EDF specification says that only (printable) ASCII characters are allowed.
- * When writing the header info, EDFlib will assume you are using Latin1 encoding and it will automatically convert
- * characters with accents, umlauts, tilde, etc. to their "normal" equivalent without the accent/umlaut/tilde/etc.
- * in order to create a valid EDF file.
- *
- * The description/name of an EDF+ annotation on the other hand, is encoded in UTF-8.
- *
- */
-
-
 struct edf_param_struct{         /* this structure contains all the relevant EDF-signal parameters of one signal */
   char   label[17];              /* label (name) of the signal, null-terminated string */
   long long smp_in_file;         /* number of samples of this signal in the file */
   double phys_max;               /* physical maximum, usually the maximum input of the ADC */
   double phys_min;               /* physical minimum, usually the minimum input of the ADC */
-  int    dig_max;                /* digital maximum, usually the maximum output of the ADC, can not not be higher than 32767 for EDF or 8388607 for BDF */
-  int    dig_min;                /* digital minimum, usually the minimum output of the ADC, can not not be lower than -32768 for EDF or -8388608 for BDF */
+  int    dig_max;                /* digital maximum, usually the maximum output of the ADC, cannot not be higher than 32767 for EDF or 8388607 for BDF */
+  int    dig_min;                /* digital minimum, usually the minimum output of the ADC, cannot not be lower than -32768 for EDF or -8388608 for BDF */
   int    smp_in_datarecord;      /* number of samples of this signal in a datarecord, if the datarecord has a duration of one second (default), then it equals the samplerate */
   char   physdimension[9];       /* physical dimension (uV, bpm, mA, etc.), null-terminated string */
   char   prefilter[81];          /* null-terminated string */
   char   transducer[81];         /* null-terminated string */
       };
 
-
 struct edf_annotation_struct{                           /* this structure is used for annotations */
         long long onset;                                /* onset time of the event, expressed in units of 100 nanoSeconds and relative to the start of the file */
         char duration[16];                              /* duration time, this is a null-terminated ASCII text-string */
         char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1]; /* description of the event in UTF-8, this is a null terminated string */
        };
 
-
-struct edf_hdr_struct{                     /* this structure contains all the relevant EDF header info and will be filled when calling the function edf_open_file_readonly() */
-  int       handle;                        /* a handle (identifier) used to distinguish the different files */
-  int       filetype;                      /* 0: EDF, 1: EDFplus, 2: BDF, 3: BDFplus, a negative number means an error */
-  int       edfsignals;                    /* number of EDF signals in the file, annotation channels are NOT included */
-  long long file_duration;                 /* duration of the file expressed in units of 100 nanoSeconds */
+struct edf_hdr_struct{            /* this structure contains all the relevant EDF header info and will be filled when calling the function edf_open_file_readonly() */
+  int       handle;               /* a handle (identifier) used to distinguish the different files */
+  int       filetype;             /* 0: EDF, 1: EDF+, 2: BDF, 3: BDF+, a negative number means an error */
+  int       edfsignals;           /* number of EDF signals in the file, annotation channels are NOT included */
+  long long file_duration;        /* duration of the file expressed in units of 100 nanoSeconds */
   int       startdate_day;
   int       startdate_month;
   int       startdate_year;
-  long long starttime_subsecond;                          /* starttime offset expressed in units of 100 nanoSeconds. Is always less than 10000000 (one second). Only used by EDFplus and BDFplus */
+  long long starttime_subsecond;  /* starttime offset expressed in units of 100 nanoSeconds. Is always less than 10000000 (one second). Only used by EDF+ and BDF+ */
   int       starttime_second;
   int       starttime_minute;
   int       starttime_hour;
@@ -193,509 +199,458 @@ struct edf_hdr_struct{                     /* this structure contains all the re
   struct edf_param_struct signalparam[EDFLIB_MAXSIGNALS]; /* array of structs which contain the relevant signal parameters */
        };
 
-
-
-
 /*****************  the following functions are used to read files **************************/
 
 int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int read_annotations);
-
-/* opens an existing file for reading */
-/* path is a null-terminated string containing the path to the file */
-/* hdr is a pointer to an edf_hdr_struct, all fields in this struct will be overwritten */
-/* the edf_hdr_struct will be filled with all the relevant header- and signalinfo/parameters */
-
-/* read_annotations must have one of the following values:      */
-/*   EDFLIB_DO_NOT_READ_ANNOTATIONS      annotations will not be read (this saves time when opening a very large EDFplus or BDFplus file */
-/*   EDFLIB_READ_ANNOTATIONS             annotations will be read immediately, stops when an annotation has */
-/*                                       been found which contains the description "Recording ends"         */
-/*   EDFLIB_READ_ALL_ANNOTATIONS         all annotations will be read immediately                           */
-
-/* returns 0 on success, in case of an error it returns -1 and an errorcode will be set in the member "filetype" of struct edf_hdr_struct */
-/* This function is required if you want to read a file */
-
-
+/* opens an existing file for reading
+ * path is a null-terminated string containing the path to the file
+ * hdr is a pointer to an edf_hdr_struct, all fields in this struct will be overwritten
+ * the edf_hdr_struct will be filled with all the relevant header- and signalinfo/parameters
+
+ * read_annotations must have one of the following values:
+ *   EDFLIB_DO_NOT_READ_ANNOTATIONS      annotations will not be read (this saves time when opening a very large EDF+ or BDF+ file
+ *   EDFLIB_READ_ANNOTATIONS             annotations will be read immediately, stops when an annotation has
+ *                                       been found which contains the description "Recording ends"
+ *   EDFLIB_READ_ALL_ANNOTATIONS         all annotations will be read immediately
+
+ * returns 0 on success, in case of an error it returns -1 and an errorcode will be set in the member "filetype" of struct edf_hdr_struct
+ * This function is required if you want to read a file
+ */
 
 int edfread_physical_samples(int handle, int edfsignal, int n, double *buf);
-
-/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0) */
-/* the values are converted to their physical values e.g. microVolts, beats per minute, etc. */
-/* bufsize should be equal to or bigger than sizeof(double[n]) */
-/* the sample position indicator will be increased with the amount of samples read */
-/* returns the amount of samples read (this can be less than n or zero!) */
-/* or -1 in case of an error */
-
+/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0)
+ * the values are converted to their physical values e.g. microVolts, beats per minute, etc.
+ * bufsize should be equal to or bigger than sizeof(double[n])
+ * the sample position indicator will be increased with the amount of samples read
+ * returns the amount of samples read (this can be less than n or zero!)
+ * or -1 in case of an error
+ */
 
 int edfread_digital_samples(int handle, int edfsignal, int n, int *buf);
-
-/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0) */
-/* the values are the "raw" digital values */
-/* bufsize should be equal to or bigger than sizeof(int[n]) */
-/* the sample position indicator will be increased with the amount of samples read */
-/* returns the amount of samples read (this can be less than n or zero!) */
-/* or -1 in case of an error */
-
+/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0)
+ * the values are the "raw" digital values
+ * bufsize should be equal to or bigger than sizeof(int[n])
+ * the sample position indicator will be increased with the amount of samples read
+ * returns the amount of samples read (this can be less than n or zero!)
+ * or -1 in case of an error
+ */
 
 long long edfseek(int handle, int edfsignal, long long offset, int whence);
-
-/* The edfseek() function sets the sample position indicator for the edfsignal pointed to by edfsignal. */
-/* The new position, measured in samples, is obtained by adding offset samples to the position specified by whence. */
-/* If whence is set to EDFSEEK_SET, EDFSEEK_CUR, or EDFSEEK_END, the offset is relative to the start of the file, */
-/* the current position indicator, or end-of-file, respectively. */
-/* Returns the current offset. Otherwise, -1 is returned. */
-/* note that every signal has it's own independent sample position indicator and edfseek() affects only one of them */
-
+/* The edfseek() function sets the sample position indicator for the edfsignal pointed to by edfsignal.
+ * The new position, measured in samples, is obtained by adding offset samples to the position specified by whence.
+ * If whence is set to EDFSEEK_SET, EDFSEEK_CUR, or EDFSEEK_END, the offset is relative to the start of the file,
+ * the current position indicator, or end-of-file, respectively.
+ * Returns the current offset. Otherwise, -1 is returned.
+ * note that every signal has it's own independent sample position indicator and edfseek() affects only one of them
+ */
 
 long long edftell(int handle, int edfsignal);
-
-/* The edftell() function obtains the current value of the sample position indicator for the edfsignal pointed to by edfsignal. */
-/* Returns the current offset. Otherwise, -1 is returned */
-/* note that every signal has it's own independent sample position indicator and edftell() affects only one of them */
-
+/* The edftell() function obtains the current value of the sample position indicator for the edfsignal pointed to by edfsignal.
+ * Returns the current offset. Otherwise, -1 is returned
+ * note that every signal has it's own independent sample position indicator and edftell() affects only one of them
+ */
 
 void edfrewind(int handle, int edfsignal);
-
-/* The edfrewind() function sets the sample position indicator for the edfsignal pointed to by edfsignal to the beginning of the file. */
-/* It is equivalent to: (void) edfseek(int handle, int edfsignal, 0LL, EDFSEEK_SET) */
-/* note that every signal has it's own independent sample position indicator and edfrewind() affects only one of them */
-
+/* The edfrewind() function sets the sample position indicator for the edfsignal pointed to by edfsignal to the beginning of the file.
+ * It is equivalent to: (void) edfseek(int handle, int edfsignal, 0LL, EDFSEEK_SET)
+ * note that every signal has it's own independent sample position indicator and edfrewind() affects only one of them
+ */
 
 int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot);
+/* Fills the edf_annotation_struct with the annotation n, returns 0 on success, otherwise -1
+ * The string that describes the annotation/event is encoded in UTF-8
+ * To obtain the number of annotations in a file, check edf_hdr_struct -> annotations_in_file.
+ * returns 0 on success or -1 in case of an error
+ */
 
-/* Fills the edf_annotation_struct with the annotation n, returns 0 on success, otherwise -1 */
-/* The string that describes the annotation/event is encoded in UTF-8 */
-/* To obtain the number of annotations in a file, check edf_hdr_struct -> annotations_in_file. */
-/* returns 0 on success or -1 in case of an error */
-
-/*
-Notes:
-
-Annotationsignals
-=================
-
-EDFplus and BDFplus store the annotations in one or more signals (in order to be backwards compatibel with EDF and BDF).
-The counting of the signals in the file starts at 0. Signals used for annotations are skipped by EDFlib.
-This means that the annotationsignal(s) in the file are hided.
-Use the function edf_get_annotation() to get the annotations.
-
-So, when a file contains 5 signals and the third signal is used to store the annotations, the library will
-report that there are only 4 signals in the file.
-The library will "map" the signalnumbers as follows: 0->0, 1->1, 2->3, 3->4.
-This way you don't need to worry about which signals are annotationsignals, the library will take care of it.
-
-How the library stores time-values
-==================================
-
-To avoid rounding errors, the library stores some timevalues in variables of type long long int.
-In order not to loose the subsecond precision, all timevalues have been multiplied by 10000000.
-This will limit the timeresolution to 100 nanoSeconds. To calculate the amount of seconds, divide
-the timevalue by 10000000 or use the macro EDFLIB_TIME_DIMENSION which is declared in edflib.h.
-The following variables do use this when you open a file in read mode: "file_duration", "starttime_subsecond" and "onset".
-*/
-
-/*****************  the following functions are used to read or write files **************************/
+/*****************  the following functions are used in read and write mode **************************/
 
 int edfclose_file(int handle);
-
-/* closes (and in case of writing, finalizes) the file */
-/* returns -1 in case of an error, 0 on success */
-/* this function MUST be called when you are finished reading or writing */
-/* This function is required after reading or writing. Failing to do so will cause */
-/* unnessecary memory usage and in case of writing it will cause a corrupted and incomplete file */
-
+/* closes (and in case of writing, finalizes) the file
+ * returns -1 in case of an error, 0 on success
+ * this function MUST be called when you are finished reading or writing
+ * This function is required after reading or writing. Failing to do so will cause
+ * unnessecary memory usage and in case of writing it will cause a corrupted and incomplete file
+ */
 
 int edflib_version(void);
-
-/* Returns the version number of this library, multiplied by hundred. if version is "1.00" than it will return 100 */
-
+/* Returns the version number of this library, multiplied by hundred. if version is "1.00" than it will return 100
+ */
 
 int edflib_is_file_used(const char *path);
-
-/* returns 1 if the file is used, either for reading or writing */
-/* otherwise returns 0 */
-
+/* returns 1 if the file is used, either for reading or writing, otherwise returns 0
+ */
 
 int edflib_get_number_of_open_files(void);
-
-/* returns the number of open files, either for reading or writing */
-
+/* returns the number of open files, either for reading or writing
+ */
 
 int edflib_get_handle(int file_number);
-
-/* returns the handle of an opened file, either for reading or writing */
-/* file_number starts with 0 */
-/* returns -1 if the file is not opened */
-
+/* returns the handle of an opened file, either for reading or writing
+ * file_number is zero based (starts with 0)
+ * returns -1 if the file is not opened
+ */
 
 /*****************  the following functions are used to write files **************************/
 
-
 int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals);
+/* opens an new file for writing. warning, an already existing file with the same name will be silently overwritten without advance warning!
+ * path is a null-terminated string containing the path and name of the file
+ * filetype must be EDFLIB_FILETYPE_EDFPLUS or EDFLIB_FILETYPE_BDFPLUS
+ * returns a handle on success, you need this handle for the other functions
+ * in case of an error it returns a negative number corresponding to one of the following values:
+ * EDFLIB_MALLOC_ERROR
+ * EDFLIB_NO_SUCH_FILE_OR_DIRECTORY
+ * EDFLIB_MAXFILES_REACHED
+ * EDFLIB_FILE_ALREADY_OPENED
+ * EDFLIB_NUMBER_OF_SIGNALS_INVALID
+ * This function is required if you want to write a file (or use edfopen_file_writeonly_with_params())
+ */
 
-/* opens an new file for writing. warning, an already existing file with the same name will be silently overwritten without advance warning!! */
-/* path is a null-terminated string containing the path and name of the file */
-/* filetype must be EDFLIB_FILETYPE_EDFPLUS or EDFLIB_FILETYPE_BDFPLUS */
-/* returns a handle on success, you need this handle for the other functions */
-/* in case of an error it returns a negative number corresponding to one of the following values: */
-/* EDFLIB_MALLOC_ERROR                */
-/* EDFLIB_NO_SUCH_FILE_OR_DIRECTORY   */
-/* EDFLIB_MAXFILES_REACHED            */
-/* EDFLIB_FILE_ALREADY_OPENED         */
-/* EDFLIB_NUMBER_OF_SIGNALS_INVALID   */
-/* This function is required if you want to write a file */
-
+int edfopen_file_writeonly_with_params(const char *path, int filetype, int number_of_signals, int samplefrequency, double phys_max_min, const char *phys_dim);
+/* this is a convenience function that can create a new EDF file and initializes the most important parameters.
+ * it assumes that all signals are sharing the same parameters (you can still change them though).
+ * warning, an already existing file with the same name will be silently overwritten without advance warning!
+ * path is a null-terminated string containing the path and name of the file
+ * filetype must be EDFLIB_FILETYPE_EDFPLUS or EDFLIB_FILETYPE_BDFPLUS
+ * Sets the samplefrequency of all signals. (In reality, it sets the number of samples per datarecord which equals the samplefrequency only when
+ * the datarecords have a duration of 1 second)
+ * Sets the physical maximum of all signals to phys_max_min.
+ * Sets the physical minimum of all signals to -phys_max_min.
+ * Sets the physical dimension (unit) of all signals ("uV", "BPM", "mA", "Degr.", etc.).
+ * phys_dim is a pointer to a NULL-terminated ASCII-string containing the physical dimension of the signals
+ * returns a handle on success, you need this handle for the other functions
+ * in case of an error it returns a negative number corresponding to one of the following values:
+ * EDFLIB_MALLOC_ERROR
+ * EDFLIB_NO_SUCH_FILE_OR_DIRECTORY
+ * EDFLIB_MAXFILES_REACHED
+ * EDFLIB_FILE_ALREADY_OPENED
+ * EDFLIB_NUMBER_OF_SIGNALS_INVALID
+ * This function is required if you want to write a file (or use edfopen_file_writeonly())
+ */
 
 int edf_set_samplefrequency(int handle, int edfsignal, int samplefrequency);
-
-/* Sets the samplefrequency of signal edfsignal. (In reallity, it sets the number of samples in a datarecord.) */
-/* Returns 0 on success, otherwise -1 */
-/* This function is required for every signal and can be called only after opening a */
-/* file in writemode and before the first sample write action */
-
+/* Sets the samplefrequency of signal edfsignal. In reality, it sets the number of samples in a datarecord
+ * which equals the samplefrequency only when the datarecords have a duration of 1 second.
+ * The effective samplefrequency is: samplefrequency / datarecord duration
+ * Returns 0 on success, otherwise -1
+ * This function is required for every signal and can be called only after opening a
+ * file in writemode and before the first sample write action
+ */
 
 int edf_set_physical_maximum(int handle, int edfsignal, double phys_max);
-
-/* Sets the maximum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital maximum") */
-/* It is the highest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level */
-/* Must be un-equal to physical minimum */
-/* Returns 0 on success, otherwise -1 */
-/* This function is required for every signal and can be called only after opening a */
-/* file in writemode and before the first sample write action */
-
+/* Sets the maximum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital maximum")
+ * It is the highest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level
+ * Must be un-equal to physical minimum
+ * Returns 0 on success, otherwise -1
+ * This function is required for every signal and can be called only after opening a
+ * file in writemode and before the first sample write action
+ */
 
 int edf_set_physical_minimum(int handle, int edfsignal, double phys_min);
-
-/* Sets the minimum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital minimum") */
-/* It is the lowest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level */
-/* Usually this will be (-(phys_max)) */
-/* Must be un-equal to physical maximum */
-/* Returns 0 on success, otherwise -1 */
-/* This function is required for every signal and can be called only after opening a */
-/* file in writemode and before the first sample write action */
-
+/* Sets the minimum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital minimum")
+ * It is the lowest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level
+ * Usually this will be (-(phys_max))
+ * Must be un-equal to physical maximum
+ * Returns 0 on success, otherwise -1
+ * This function is required for every signal and can be called only after opening a
+ * file in writemode and before the first sample write action
+ */
 
 int edf_set_digital_maximum(int handle, int edfsignal, int dig_max);
-
-/* Sets the maximum digital value of signal edfsignal. The maximum value is 32767 for EDF+ and 8388607 for BDF+ */
-/* It is the highest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level */
-/* Usually it's the extreme output of the ADC */
-/* Must be higher than digital minimum */
-/* Returns 0 on success, otherwise -1 */
-/* This function is required for every signal and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the maximum digital value of signal edfsignal. The maximum value is 32767 for EDF+ and 8388607 for BDF+
+ * It is the highest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level
+ * Usually it's the extreme output of the ADC
+ * Must be higher than digital minimum
+ * Returns 0 on success, otherwise -1
+ * This function is required for every signal and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_digital_minimum(int handle, int edfsignal, int dig_min);
-
-/* Sets the minimum digital value of signal edfsignal. The minimum value is -32768 for EDF+ and -8388608 for BDF+ */
-/* It is the lowest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level */
-/* Usually it's the extreme output of the ADC */
-/* Usually this will be (-(dig_max + 1)) */
-/* Must be lower than digital maximum */
-/* Returns 0 on success, otherwise -1 */
-/* This function is required for every signal and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the minimum digital value of signal edfsignal. The minimum value is -32768 for EDF+ and -8388608 for BDF+
+ * It is the lowest value that the equipment is able to record. It does not necessarily mean the signal recorded reaches this level
+ * Usually it's the extreme output of the ADC
+ * Usually this will be (-(dig_max + 1))
+ * Must be lower than digital maximum
+ * Returns 0 on success, otherwise -1
+ * This function is required for every signal and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_label(int handle, int edfsignal, const char *label);
-
-/* Sets the label (name) of signal edfsignal. ("FP1", "SaO2", etc.) */
-/* label is a pointer to a NULL-terminated ASCII-string containing the label (name) of the signal edfsignal */
-/* Returns 0 on success, otherwise -1 */
-/* This function is recommended for every signal when you want to write a file */
-/* and can be called only after opening a file in writemode and before the first sample write action */
-
+/* Sets the label (name) of signal edfsignal. ("FP1", "SaO2", etc.)
+ * label is a pointer to a NULL-terminated ASCII-string containing the label (name) of the signal edfsignal
+ * Returns 0 on success, otherwise -1
+ * This function is recommended for every signal when you want to write a file
+ * and can be called only after opening a file in writemode and before the first sample write action
+ */
 
 int edf_set_prefilter(int handle, int edfsignal, const char *prefilter);
-
-/* Sets the prefilter of signal edfsignal ("HP:0.1Hz", "LP:75Hz N:50Hz", etc.). */
-/* prefilter is a pointer to a NULL-terminated ASCII-string containing the prefilter text of the signal edfsignal */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode and before */
-/* the first sample write action */
-
+/* Sets the prefilter of signal edfsignal ("HP:0.1Hz", "LP:75Hz N:50Hz", etc.).
+ * prefilter is a pointer to a NULL-terminated ASCII-string containing the prefilter text of the signal edfsignal
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode and before
+ * the first sample write action
+ */
 
 int edf_set_transducer(int handle, int edfsignal, const char *transducer);
-
-/* Sets the transducer of signal edfsignal ("AgAgCl cup electrodes", etc.). */
-/* transducer is a pointer to a NULL-terminated ASCII-string containing the transducer text of the signal edfsignal */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode and before */
-/* the first sample write action */
-
+/* Sets the transducer of signal edfsignal ("AgAgCl cup electrodes", etc.).
+ * transducer is a pointer to a NULL-terminated ASCII-string containing the transducer text of the signal edfsignal
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode and before
+ * the first sample write action
+ */
 
 int edf_set_physical_dimension(int handle, int edfsignal, const char *phys_dim);
-
-/* Sets the physical dimension (unit) of signal edfsignal. ("uV", "BPM", "mA", "Degr.", etc.) */
-/* phys_dim is a pointer to a NULL-terminated ASCII-string containing the physical dimension of the signal edfsignal */
-/* Returns 0 on success, otherwise -1 */
-/* This function is recommended for every signal when you want to write a file */
-/* and can be called only after opening a file in writemode and before the first sample write action */
-
+/* Sets the physical dimension (unit) of signal edfsignal. ("uV", "BPM", "mA", "Degr.", etc.)
+ * phys_dim is a pointer to a NULL-terminated ASCII-string containing the physical dimension of the signal edfsignal
+ * Returns 0 on success, otherwise -1
+ * This function is recommended for every signal when you want to write a file
+ * and can be called only after opening a file in writemode and before the first sample write action
+ */
 
 int edf_set_startdatetime(int handle, int startdate_year, int startdate_month, int startdate_day,
                                       int starttime_hour, int starttime_minute, int starttime_second);
-
-/* Sets the startdate and starttime. */
-/* year: 1985 - 2084, month: 1 - 12, day: 1 - 31 */
-/* hour: 0 - 23, minute: 0 - 59, second: 0 - 59 */
-/* If not called, the library will use the system date and time at runtime */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-/* Note: for anonymization purposes, the consensus is to use 1985-01-01 00:00:00 for the startdate and starttime. */
-
+/* Sets the startdate and starttime.
+ * year: 1985 - 2084, month: 1 - 12, day: 1 - 31
+ * hour: 0 - 23, minute: 0 - 59, second: 0 - 59
+ * If not called, the library will use the system date and time at runtime
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ * Note: for anonymization purposes, the consensus is to use 1985-01-01 00:00:00 for the startdate and starttime.
+ */
 
 int edf_set_patientname(int handle, const char *patientname);
-
-/* Sets the patientname. patientname is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the patientname. patientname is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_patientcode(int handle, const char *patientcode);
-
-/* Sets the patientcode. patientcode is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the patientcode. patientcode is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_gender(int handle, int gender);
-
-/* Sets the gender. 1 is male, 0 is female. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
-
+/* Sets the gender. 1 is male, 0 is female.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_birthdate(int handle, int birthdate_year, int birthdate_month, int birthdate_day);
-
-/* Sets the birthdate. */
-/* year: 1800 - 3000, month: 1 - 12, day: 1 - 31 */
-/* This function is optional */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the birthdate.
+ * year: 1800 - 3000, month: 1 - 12, day: 1 - 31
+ * This function is optional
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_patient_additional(int handle, const char *patient_additional);
-
-/* Sets the additional patientinfo. patient_additional is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the additional patientinfo. patient_additional is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_admincode(int handle, const char *admincode);
-
-/* Sets the admincode. admincode is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the admincode. admincode is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_technician(int handle, const char *technician);
-
-/* Sets the technicians name. technician is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the technicians name. technician is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_equipment(int handle, const char *equipment);
-
-/* Sets the name of the equipment used during the aquisition. equipment is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the name of the equipment used during the aquisition. equipment is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edf_set_recording_additional(int handle, const char *recording_additional);
-
-/* Sets the additional recordinginfo. recording_additional is a pointer to a null-terminated ASCII-string. */
-/* Returns 0 on success, otherwise -1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-
+/* Sets the additional recordinginfo. recording_additional is a pointer to a null-terminated ASCII-string.
+ * Returns 0 on success, otherwise -1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ */
 
 int edfwrite_physical_samples(int handle, double *buf);
-
-/* Writes n physical samples (uV, mA, Ohm) from *buf belonging to one signal */
-/* where n is the samplefrequency of that signal. */
-/* The physical samples will be converted to digital samples using the */
-/* values of physical maximum, physical minimum, digital maximum and digital minimum */
-/* The number of samples written is equal to the samplefrequency of the signal */
-/* Size of buf should be equal to or bigger than sizeof(double[samplefrequency]) */
-/* Call this function for every signal in the file. The order is important! */
-/* When there are 4 signals in the file,  the order of calling this function */
-/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes n physical samples (uV, mA, Ohm) from *buf belonging to one signal
+ * where n is the samplefrequency of that signal.
+ * The physical samples will be converted to digital samples using the
+ * values of physical maximum, physical minimum, digital maximum and digital minimum
+ * The number of samples written is equal to the samplefrequency of the signal
+ * Size of buf should be equal to or bigger than sizeof(double[samplefrequency])
+ * Call this function for every signal in the file. The order is important!
+ * When there are 4 signals in the file,  the order of calling this function
+ * must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc.
+ * Returns 0 on success, otherwise -1
+ */
 
 int edf_blockwrite_physical_samples(int handle, double *buf);
-
-/* Writes physical samples (uV, mA, Ohm) from *buf */
-/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
-/* where n is the samplefrequency of that signal. */
-/* buf must be filled with samples from all signals, starting with signal 0, 1, 2, etc. */
-/* one block equals one second */
-/* The physical samples will be converted to digital samples using the */
-/* values of physical maximum, physical minimum, digital maximum and digital minimum */
-/* The number of samples written is equal to the sum of the samplefrequencies of all signals */
-/* Size of buf should be equal to or bigger than sizeof(double) multiplied by the sum of the samplefrequencies of all signals */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes physical samples (uV, mA, Ohm) from *buf
+ * buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc.
+ * where n is the samplefrequency of that signal.
+ * buf must be filled with samples from all signals, starting with signal 0, 1, 2, etc.
+ * one block equals one second
+ * The physical samples will be converted to digital samples using the
+ * values of physical maximum, physical minimum, digital maximum and digital minimum
+ * The number of samples written is equal to the sum of the samplefrequencies of all signals
+ * Size of buf should be equal to or bigger than sizeof(double) multiplied by the sum of the samplefrequencies of all signals
+ * Returns 0 on success, otherwise -1
+ */
 
 int edfwrite_digital_short_samples(int handle, short *buf);
-
-/* Writes n "raw" digital samples from *buf belonging to one signal */
-/* where n is the samplefrequency of that signal. */
-/* The samples will be written to the file without any conversion. */
-/* Because the size of a short is 16-bit, do not use this function with BDF (24-bit) */
-/* The number of samples written is equal to the samplefrequency of the signal */
-/* Size of buf should be equal to or bigger than sizeof(short[samplefrequency]) */
-/* Call this function for every signal in the file. The order is important! */
-/* When there are 4 signals in the file,  the order of calling this function */
-/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes n "raw" digital samples from *buf belonging to one signal
+ * where n is the samplefrequency of that signal.
+ * The samples will be written to the file without any conversion.
+ * Because the size of a short is 16-bit, do not use this function with BDF (24-bit)
+ * The number of samples written is equal to the samplefrequency of the signal
+ * Size of buf should be equal to or bigger than sizeof(short[samplefrequency])
+ * Call this function for every signal in the file. The order is important!
+ * When there are 4 signals in the file,  the order of calling this function
+ * must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc.
+ * Returns 0 on success, otherwise -1
+ */
 
 int edfwrite_digital_samples(int handle, int *buf);
-
-/* Writes n "raw" digital samples from *buf belonging to one signal */
-/* where n is the samplefrequency of that signal. */
-/* The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the */
-/* file without any conversion. */
-/* The number of samples written is equal to the samplefrequency of the signal */
-/* Size of buf should be equal to or bigger than sizeof(int[samplefrequency]) */
-/* Call this function for every signal in the file. The order is important! */
-/* When there are 4 signals in the file,  the order of calling this function */
-/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes n "raw" digital samples from *buf belonging to one signal
+ * where n is the samplefrequency of that signal.
+ * The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the
+ * file without any conversion.
+ * The number of samples written is equal to the samplefrequency of the signal
+ * Size of buf should be equal to or bigger than sizeof(int[samplefrequency])
+ * Call this function for every signal in the file. The order is important!
+ * When there are 4 signals in the file,  the order of calling this function
+ * must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc.
+ * Returns 0 on success, otherwise -1
+ */
 
 int edf_blockwrite_digital_3byte_samples(int handle, void *buf);
-
-/* Writes "raw" digital samples from *buf. */
-/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
-/* where n is the samplefrequency of that signal. */
-/* One block equals one second. One sample equals 3 bytes, order is little endian (least significant byte first) */
-/* Encoding is second's complement, most significant bit of most significant byte is the sign-bit */
-/* The samples will be written to the file without any conversion. */
-/* Because the size of a 3-byte sample is 24-bit, this function can only be used when writing a BDF file */
-/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
-/* Size of buf should be equal to or bigger than: the sum of the samplefrequencies of all signals x 3 bytes */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes "raw" digital samples from *buf.
+ * buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc.
+ * where n is the samplefrequency of that signal.
+ * One block equals one second. One sample equals 3 bytes, order is little endian (least significant byte first)
+ * Encoding is second's complement, most significant bit of most significant byte is the sign-bit
+ * The samples will be written to the file without any conversion.
+ * Because the size of a 3-byte sample is 24-bit, this function can only be used when writing a BDF file
+ * The number of samples written is equal to the sum of the samplefrequencies of all signals.
+ * Size of buf should be equal to or bigger than: the sum of the samplefrequencies of all signals x 3 bytes
+ * Returns 0 on success, otherwise -1
+ */
 
 int edf_blockwrite_digital_short_samples(int handle, short *buf);
-
-/* Writes "raw" digital samples from *buf. */
-/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
-/* where n is the samplefrequency of that signal. */
-/* One block equals one second. */
-/* The samples will be written to the file without any conversion. */
-/* Because the size of a short is 16-bit, do not use this function with BDF (24-bit) */
-/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
-/* Size of buf should be equal to or bigger than sizeof(short) multiplied by the sum of the samplefrequencies of all signals */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes "raw" digital samples from *buf.
+ * buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc.
+ * where n is the samplefrequency of that signal.
+ * One block equals one second.
+ * The samples will be written to the file without any conversion.
+ * Because the size of a short is 16-bit, do not use this function with BDF (24-bit)
+ * The number of samples written is equal to the sum of the samplefrequencies of all signals.
+ * Size of buf should be equal to or bigger than sizeof(short) multiplied by the sum of the samplefrequencies of all signals
+ * Returns 0 on success, otherwise -1
+ */
 
 int edf_blockwrite_digital_samples(int handle, int *buf);
-
-/* Writes "raw" digital samples from *buf. */
-/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
-/* where n is the samplefrequency of that signal. */
-/* One block equals one second. */
-/* The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the */
-/* file without any conversion. */
-/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
-/* Size of buf should be equal to or bigger than sizeof(int) multiplied by the sum of the samplefrequencies of all signals */
-/* Returns 0 on success, otherwise -1 */
-
+/* Writes "raw" digital samples from *buf.
+ * buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc.
+ * where n is the samplefrequency of that signal.
+ * One block equals one second.
+ * The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the
+ * file without any conversion.
+ * The number of samples written is equal to the sum of the samplefrequencies of all signals.
+ * Size of buf should be equal to or bigger than sizeof(int) multiplied by the sum of the samplefrequencies of all signals
+ * Returns 0 on success, otherwise -1
+ */
 
 int edfwrite_annotation_utf8(int handle, long long onset, long long duration, const char *description);
-
-/* writes an annotation/event to the file */
-/* onset is relative to the start of the file */
-/* onset and duration are in units of 100 microSeconds!     resolution is 0.0001 second! */
-/* for example: 34.071 seconds must be written as 340710 */
-/* if duration is unknown or not applicable: set a negative number (-1) */
-/* description is a null-terminated UTF8-string containing the text that describes the event */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before closing the file */
-
+/* writes an annotation/event to the file
+ * onset is relative to the start of the file
+ * onset and duration are in units of 100 microSeconds!     resolution is 0.0001 second!
+ * for example: 34.071 seconds must be written as 340710
+ * if duration is unknown or not applicable: set a negative number (-1)
+ * description is a null-terminated UTF8-string containing the text that describes the event
+ * This function is optional and can be called only after opening a file in writemode
+ * and before closing the file
+ */
 
 int edfwrite_annotation_latin1(int handle, long long onset, long long duration, const char *description);
-
-/* writes an annotation/event to the file */
-/* onset is relative to the start of the file */
-/* onset and duration are in units of 100 microSeconds!     resolution is 0.0001 second! */
-/* for example: 34.071 seconds must be written as 340710 */
-/* if duration is unknown or not applicable: set a negative number (-1) */
-/* description is a null-terminated Latin1-string containing the text that describes the event */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before closing the file */
-
+/* writes an annotation/event to the file
+ * onset is relative to the start of the file
+ * onset and duration are in units of 100 microSeconds!     resolution is 0.0001 second!
+ * for example: 34.071 seconds must be written as 340710
+ * if duration is unknown or not applicable: set a negative number (-1)
+ * description is a null-terminated Latin1-string containing the text that describes the event
+ * This function is optional and can be called only after opening a file in writemode
+ * and before closing the file
+ */
 
 int edf_set_datarecord_duration(int handle, int duration);
-
-/* Sets the datarecord duration. The default value is 1 second. */
-/* ATTENTION: the argument "duration" is expressed in units of 10 microSeconds! */
-/* So, if you want to set the datarecord duration to 0.1 second, you must give */
-/* the argument "duration" a value of "10000". */
-/* This function is optional, normally you don't need to change the default value. */
-/* The datarecord duration must be in the range 0.001 to 60 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. */
-/* This function can be used when you want to use a samplerate */
-/* which is not an integer. For example, if you want to use a samplerate of 0.5 Hz, */
-/* set the samplefrequency to 5 Hz and the datarecord duration to 10 seconds, */
-/* or set the samplefrequency to 1 Hz and the datarecord duration to 2 seconds. */
-/* Do not use this function if not necessary. */
-
+/* Sets the datarecord duration. The default value is 1 second.
+ * ATTENTION: the argument "duration" is expressed in units of 10 microSeconds!
+ * So, if you want to set the datarecord duration to 0.1 second, you must give
+ * the argument "duration" a value of "10000".
+ * This function is optional, normally you don't need to change the default value.
+ * The datarecord duration must be in the range 0.001 to 60 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.
+ * This function can be used when you want to use a samplerate
+ * which is not an integer. For example, if you want to use a samplerate of 0.5 Hz,
+ * set the samplefrequency to 5 Hz and the datarecord duration to 10 seconds,
+ * or set the samplefrequency to 1 Hz and the datarecord duration to 2 seconds.
+ * Do not use this function if not necessary.
+ */
 
 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 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. */
-/* This function can be used when you want to use a very high samplerate. */
-/* For example, if you want to use a samplerate of 5 GHz, */
-/* set the samplefrequency to 5000 Hz and the datarecord duration to 1 micro-second. */
-/* Do not use this function if not necessary. */
-/* This function was added to accommodate for high speed ADC's e.g. Digital Sampling Oscilloscopes */
-
+/* 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 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.
+ * This function can be used when you want to use a very high samplerate.
+ * For example, if you want to use a samplerate of 5 GHz,
+ * set the samplefrequency to 5000 Hz and the datarecord duration to 1 micro-second.
+ * Do not use this function if not necessary.
+ * This function was added to accommodate for high speed ADC's e.g. Digital Sampling Oscilloscopes
+ */
 
 int edf_set_number_of_annotation_signals(int handle, int annot_signals);
-
-/* Sets the number of annotation signals. The default value is 1 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-/* Normally you don't need to change the default value. Only when the number of annotations */
-/* you want to write is higher than the number of datarecords in the recording, you can use */
-/* this function to increase the storage space for annotations */
-/* Minimum is 1, maximum is 64 */
-/* Returns 0 on success, otherwise -1 */
-
+/* Sets the number of annotation signals. The default value is 1
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ * Normally you don't need to change the default value. Only when the number of annotations
+ * you want to write is higher than the number of datarecords in the recording, you can use
+ * this function to increase the storage space for annotations
+ * Minimum is 1, maximum is 64
+ * Returns 0 on success, otherwise -1
+ */
 
 int edf_set_subsecond_starttime(int handle, int subsecond);
-/* Sets the subsecond starttime expressed in units of 100 nanoSeconds */
-/* Valid range is 0 to 9999999 inclusive. Default is 0 */
-/* This function is optional and can be called only after opening a file in writemode */
-/* and before the first sample write action */
-/* Returns 0 on success, otherwise -1 */
-/* It is strongly recommended to use a maximum resolution of no more than 100 micro-Seconds. */
-/* e.g. use 1234000  to set a starttime offset of 0.1234 seconds (instead of 1234567) */
-/* in other words, leave the last 3 digits at zero */
+/* Sets the subsecond starttime expressed in units of 100 nanoSeconds
+ * Valid range is 0 to 9999999 inclusive. Default is 0
+ * This function is optional and can be called only after opening a file in writemode
+ * and before the first sample write action
+ * Returns 0 on success, otherwise -1
+ * It is strongly recommended to use a maximum resolution of no more than 100 micro-Seconds.
+ * e.g. use 1234000  to set a starttime offset of 0.1234 seconds (instead of 1234567)
+ * in other words, leave the last 3 digits at zero
+ */
 
 #ifdef __cplusplus
 } /* extern "C" */


=====================================
unittest/unittest.c
=====================================
@@ -78,7 +78,7 @@ int main(void)
 
   setlocale(LC_ALL, "C");
 
-  if(edflib_version() != 119)  JUMP_TO_EXIT_ERROR_PROC
+  if(edflib_version() != 120)  JUMP_TO_EXIT_ERROR_PROC
 
   ibuf = (int *)malloc(100 * sizeof(int));
   if(ibuf == NULL)
@@ -111,6 +111,71 @@ int main(void)
     JUMP_TO_EXIT_ERROR_PROC;
   }
 
+/********************************** EDF writing ******************************/
+
+  hdl = edfopen_file_writeonly_with_params("test.edf", EDFLIB_FILETYPE_EDFPLUS, 65, 633, 3000, "uV");
+
+  if(hdl < 0)  JUMP_TO_EXIT_ERROR_PROC
+
+  for(i=0; i<633; i++)
+  {
+    dbuf[i] = i;
+  }
+
+  for(i=0; i<10; i++)
+  {
+    for(j=0; j<65; j++)
+    {
+      if(edfwrite_physical_samples(hdl, dbuf))  JUMP_TO_EXIT_ERROR_PROC
+    }
+  }
+
+  if(edfclose_file(hdl))
+  {
+    hdl = -1;
+
+    JUMP_TO_EXIT_ERROR_PROC
+  }
+
+/********************************** EDF reading ******************************/
+
+  if(edfopen_file_readonly("test.edf", &hdr, EDFLIB_READ_ALL_ANNOTATIONS))  JUMP_TO_EXIT_ERROR_PROC
+
+  hdl = hdr.handle;
+
+  if(hdr.filetype != 1)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.edfsignals != 65)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.file_duration != 100000000)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.datarecord_duration != 10000000)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.datarecords_in_file != 10)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].smp_in_file != 6330)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].phys_max != 3000)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].phys_min != -3000)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].dig_max != 32767)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].dig_min != -32768)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(hdr.signalparam[0].smp_in_datarecord != 633)  JUMP_TO_EXIT_ERROR_PROC
+
+  if(strcmp(hdr.signalparam[0].physdimension, "uV      "))  JUMP_TO_EXIT_ERROR_PROC
+
+  if(edfclose_file(hdl))
+  {
+    hdl = -1;
+
+    JUMP_TO_EXIT_ERROR_PROC
+  }
+
+  hdl = -1;
+
 /********************************** EDF writing ******************************/
 
   hdl = edfopen_file_writeonly("test.edf", EDFLIB_FILETYPE_EDFPLUS, 512);
@@ -230,7 +295,7 @@ int main(void)
 
   if(edf_set_startdatetime(hdl, 2017, 12, 5, 12, 23, 8))  JUMP_TO_EXIT_ERROR_PROC
 
-  if(edf_set_patientname(hdl, "John Doe"))  JUMP_TO_EXIT_ERROR_PROC
+  if(edf_set_patientname(hdl, "John Do"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_set_patientcode(hdl, "01234"))  JUMP_TO_EXIT_ERROR_PROC
 
@@ -242,7 +307,7 @@ int main(void)
 
   if(edf_set_admincode(hdl, "789"))  JUMP_TO_EXIT_ERROR_PROC
 
-  if(edf_set_technician(hdl, "Richard Roe"))  JUMP_TO_EXIT_ERROR_PROC
+  if(edf_set_technician(hdl, "Rchard Ro"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(edf_set_equipment(hdl, "device"))  JUMP_TO_EXIT_ERROR_PROC
 
@@ -643,7 +708,7 @@ int main(void)
 
   if(hdr.starttime_subsecond != 0)  JUMP_TO_EXIT_ERROR_PROC
 
-  if(strcmp(hdr.patient_name, "John Doe"))  JUMP_TO_EXIT_ERROR_PROC
+  if(strcmp(hdr.patient_name, "John Dou"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(strcmp(hdr.patientcode, "01234"))  JUMP_TO_EXIT_ERROR_PROC
 
@@ -695,7 +760,7 @@ int main(void)
 
   if(strcmp(hdr.signalparam[0].physdimension, "uVxxxxxx"))  JUMP_TO_EXIT_ERROR_PROC
 
-  if(strcmp(hdr.signalparam[1].physdimension, " C0xxxxx"))  JUMP_TO_EXIT_ERROR_PROC
+  if(strcmp(hdr.signalparam[1].physdimension, ".C0xxxxx"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(strncmp(hdr.signalparam[0].prefilter, "qwerty   ", 9))  JUMP_TO_EXIT_ERROR_PROC
 
@@ -2238,7 +2303,7 @@ int main(void)
 
   if(strcmp(hdr.signalparam[0].physdimension, "uVxxxxxx"))  JUMP_TO_EXIT_ERROR_PROC
 
-  if(strcmp(hdr.signalparam[1].physdimension, " C0xxxxx"))  JUMP_TO_EXIT_ERROR_PROC
+  if(strcmp(hdr.signalparam[1].physdimension, ".C0xxxxx"))  JUMP_TO_EXIT_ERROR_PROC
 
   if(strncmp(hdr.signalparam[0].prefilter, "qwerty   ", 9))  JUMP_TO_EXIT_ERROR_PROC
 
@@ -2370,7 +2435,14 @@ int main(void)
   {
 //    printf("%i:   %i   %i\n", i, ibuf[i], -1010000 + (i * 105300));
 
-    if(ibuf[i] != -1010000 + (i * 105300))  JUMP_TO_EXIT_ERROR_PROC
+    if(i == 0)
+    {
+      if(ibuf[i] != -1000000)  JUMP_TO_EXIT_ERROR_PROC
+    }
+    else
+    {
+      if(ibuf[i] != -1010000 + (i * 105300))  JUMP_TO_EXIT_ERROR_PROC
+    }
   }
 
   if(edfseek(hdl, 1, 46, EDFSEEK_SET) != 46)  JUMP_TO_EXIT_ERROR_PROC
@@ -2381,7 +2453,18 @@ int main(void)
   {
 //    printf("%i:   %i   %i\n", i, ibuf[i], 990000 + (i * 105300));
 
-    if(ibuf[i] != 990000 + (i * 105300))  JUMP_TO_EXIT_ERROR_PROC
+    if(i == 0)
+    {
+      if(ibuf[i] != 1000000)  JUMP_TO_EXIT_ERROR_PROC
+    }
+    else if(i >= 20)
+      {
+        if(ibuf[i] != 3000000)  JUMP_TO_EXIT_ERROR_PROC
+      }
+      else
+      {
+        if(ibuf[i] != 990000 + (i * 105300))  JUMP_TO_EXIT_ERROR_PROC
+      }
   }
 
   if(edfseek(hdl, 0, 60, EDFSEEK_SET) != 60)  JUMP_TO_EXIT_ERROR_PROC



View it on GitLab: https://salsa.debian.org/med-team/edflib/-/commit/d0c04ab841b34af61f03628651ba6fc9f0969892

-- 
View it on GitLab: https://salsa.debian.org/med-team/edflib/-/commit/d0c04ab841b34af61f03628651ba6fc9f0969892
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/20211109/68cd1814/attachment-0001.htm>


More information about the debian-med-commit mailing list