Improvements, mainly support for additional Text fields
[infodrom/dtaus] / dtaus.c
diff --git a/dtaus.c b/dtaus.c
index e79f31b..cac2bdd 100644 (file)
--- a/dtaus.c
+++ b/dtaus.c
@@ -1,6 +1,6 @@
 /*
     dtaus.c - Datenträgeraustausch mit einer Bank
-    Copyright (c) 1996  Martin Schulze <joey@artis.uni-oldenburg.de>
+    Copyright (c) 1996,8,2001  Martin Schulze <joey@infodrom.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
 
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
 
     $Id$
  */
@@ -22,6 +22,7 @@
 #include "dtaus.h"
 #include "bigint.h"
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <time.h>
@@ -54,6 +55,7 @@ dtaus_record recA[] = {
   {"BLZ", 7, 8, REQ},
   {"Referenz", 70, 10, OPT},
   {"Datum", 50, 6, IGN},
+  {"Euro", 127, 1, OPT},
   {NULL, 0, 0}
 };
 
@@ -63,7 +65,8 @@ dtaus_record recA[] = {
 #define A_BLZ  3
 #define A_REF  4
 #define A_DATE 5
-#define A_LEN  6
+#define A_EURO 6
+#define A_LEN  7
 
 dtaus_record recC[] = {
   {"Name", 93, 27, REQ},
@@ -75,6 +78,7 @@ dtaus_record recC[] = {
   {"myName", 128, 27, OPT},
   {"myKonto", 69, 10, OPT},
   {"myBLZ", 61, 8, OPT},
+  {"Euro", 182, 1, IGN},
   {"Text", 187, 29, OPT},
   {"Extension", 216, 29, OPT},
   {NULL, 0, 0}
@@ -89,9 +93,12 @@ dtaus_record recC[] = {
 #define C_MYNAM        6
 #define C_MYKTO        7
 #define C_MYBLZ        8
-#define C_TEXT 9
-#define C_EXT  10
-#define C_LEN  11
+#define C_EURO  9
+#define C_TEXT 10
+#define C_EXT  11
+#define C_LEN  12
+
+#define MAX_TEXT 60
 
 dtaus_record recE[] = {
   {"Anzahl", 10, 7, IGN},
@@ -139,6 +146,10 @@ char *upcase(char *s)
       case 'ß': *(xp++) = 'S'; *xp='S'; break;
       }
     } else
+      /*
+       * Filter out all other characters since credit institutes won't
+       * accept the file otherwise.
+       */
       *xp = ' ';
   }
   *xp = '\0';
@@ -151,7 +162,8 @@ char *downcase(char *s)
   static char x[100];
   char *cp;
 
-  strcpy (x, s);
+  memset (x, 0, sizeof (x));
+  strncpy (x, s, 99);
   
   for (cp=x;*cp;cp++)
     if (isupper(*cp))
@@ -178,7 +190,20 @@ char *strip_zeros (char *s)
   return p;
 }
 
-char dtaus_char(void *buf, unsigned int pos)
+char *strip_nondigits (char *s)
+{
+  char *p;
+  char *x;
+
+  for (x=s,p=s;*x;x++)
+    if (isdigit (*x))
+      *(p++) = *x;
+  *(p++) = '\0';
+
+  return s;
+}
+
+char dtaus_char (void *buf, unsigned int pos)
 {
   static char res;
   char *bufp = buf;
@@ -268,7 +293,7 @@ char *string2ext (char *s)
 
   res[0] = '\0';
   if (!strcmp(s, "01"))
-    sprintf (res, "Klient");
+    sprintf (res, "Kunde");
   else if (!strcmp(s, "02"))
     sprintf (res, "Text");
   else if (!strcmp(s, "03"))
@@ -281,7 +306,7 @@ char *ext2string (char *s)
   static char res[3];
 
   res[0] = '\0';
-  if (!strcmp(s, "Klient"))
+  if (!strcmp(s, "Kunde"))
     sprintf (res, "01");
   else if (!strcmp(s, "Text"))
     sprintf (res, "02");
@@ -339,6 +364,28 @@ char *extract_ident (char *line)
   return line;
 }
 
+/*
+ * Pads a string with zero's on the left side.
+ */
+char *padzeroclip (char *s, int len)
+{
+  char *p, *q;
+
+  if (strlen(s) == len) return s;
+  if (strlen(s) > len) {
+      q=s+len;
+      *(q--) = '\0';
+      return s;
+  }
+
+  q=s+len;
+  *(q--) = '\0';
+  for (p=s+strlen(s)-1;p>=s;p--)
+    *(q--)=*p;
+  for (;q>=s;) *(q--)='0';
+  return s;
+}
+
 int rec_index(char *ident, int type)
 {
   int i;
@@ -404,11 +451,11 @@ char *get_date()
 
   timer = time ( NULL );
   loctime = localtime(&timer);
-  sprintf(res, "%02d.%02d.%02d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year);
+  sprintf(res, "%02d.%02d.%02d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year % 100);
   return res;
 }
 
-void dtaus_prepareA(char *buf)
+void dtaus_prepareA (char *buf)
 {
   int i;
   time_t timer;
@@ -425,23 +472,40 @@ void dtaus_prepareA(char *buf)
   buf[3] = '8';
   buf[4] = 'A';
   for (i=15;i<15+8; i++) buf[i] = '0';
-  sprintf(tmp, "%02d%02d%2d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year);
+  sprintf(tmp, "%02d%02d%02d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year % 100);
   for (i=0; i<6; i++) buf[50+i] = tmp[i];
   for (i=56;i<56+4; i++) buf[i] = ' ';
   for (i=70;i<70+10; i++) buf[i] = '0';
   for (i=80;i<80+48; i++) buf[i] = ' ';
 }
 
-void dtaus_prepareC(char *buf)
+void dtaus_prepareC (char *buf, int normaltext, int maxtext)
 {
   int i;
+  int appendix = 0;
+  div_t res;
 
   bzero (buf, 257);
   buf[0] = '0';
-  buf[1] = '2';
-  buf[2] = '1';
-  buf[3] = '6';
+
+  if (normaltext)
+    appendix = 1;
+  if (maxtext) {
+    res = div (maxtext, 4);
+    appendix += res.quot;
+    if (res.rem) appendix++;
+  }
+  i = 187 + (appendix * 29);
+
+  /* Bail out if the number is too large, shouldn't be possible though */
+  if (i>1000)
+    exit (1);
+
+  buf[1] = (i/100)+48;i-=(i/100)*100;
+  buf[2] = (i/10)+48;i-=(i/10)*10;
+  buf[3] = i+48;
   buf[4] = 'C';
+
   for (i=31;i<31+13; i++) buf[i] = '0';
   buf[49] = ' ';
   for (i=79;i<79+11; i++) buf[i] = '0';
@@ -453,7 +517,7 @@ void dtaus_prepareC(char *buf)
   for (i=245;i<245+11; i++) buf[i] = ' ';
 }
 
-void dtaus_prepareE(char *buf)
+void dtaus_prepareE (char *buf)
 {
   int i;
 
@@ -481,35 +545,45 @@ int dtaus_writeA(FILE *f, char **values)
     }
   if (!(((values[A_TRANS][0] == 'L')||(values[A_TRANS][0] == 'G'))
        &&((values[A_TRANS][1] == 'B')||(values[A_TRANS][1] == 'K')))) {
-    fprintf (stderr, "Ungueltiger Typ, nur LK, GK, LB oder GB erlaubt.\n");
+    fprintf (stderr, "Ungültiger Typ, nur LK, GK, LB oder GB erlaubt.\n");
     return 0;
   }
 
+  i=A_NAME;if (values[i] && strlen(values[i]) > recA[i].len)
+    values[i][recA[i].len] = '\0';
+
   dtaus_prepareA(buf);
   buf[5] = values[A_TRANS][0];
   buf[6] = values[A_TRANS][1];
-  sprintf (tmp, "%08s", values[A_BLZ]);
+  sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[A_BLZ]),8));
   for (i=0; i<8; i++) buf[recA[A_BLZ].pos+i] = tmp[i];
   sprintf (tmp, "%-27s", upcase(values[A_NAME]));
   for (i=0; i<27; i++) buf[recA[A_NAME].pos+i] = tmp[i];
-  sprintf (tmp, "%010s", values[A_KTO]);
+  sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[A_KTO]),10));
   for (i=0; i<10; i++) buf[recA[A_KTO].pos+i] = tmp[i];
 
   fputs(buf, f);
   return 1;
 }
 
-int dtaus_writeC(FILE *f, char **valuesA, char **values)
+int dtaus_writeC(FILE *f, char **valuesA, char **values, char **text)
 {
   char buf[257];
+  char appendix[129];
   char tmp[30];
-  int i;
+  int i, k;
+  int maxtext = 0;
+  int fieldnr;
+  div_t res;
 
-  /*
+  if (text)
+    for (maxtext=0;text[maxtext];maxtext++);
+
+#if DEBUG
   for (i=0; (recC[i].name); i++)
     if (values[i])
       printf ("%s: %s\n", recC[i].name, values[i]);
-      */
+#endif
 
   for (i=0; (recC[i].name); i++)
     if ((recC[i].type == REQ) && !values[i]) {
@@ -522,29 +596,35 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values)
     return 0;
   }
 
-  dtaus_prepareC(buf);
-  if (!values[C_TEXT]) {
-    buf[1] = '1';
-    buf[2] = '8';
-    buf[3] = '7';
-  }
+  i=C_TEXT;if (values[i] && strlen(values[i]) > recC[i].len)
+    values[i][recC[i].len] = '\0';
+  i=C_ZWECK;if (values[i] && strlen(values[i]) > recC[i].len)
+    values[i][recC[i].len] = '\0';
+  i=C_MYNAM;if (values[i] && strlen(values[i]) > recC[i].len)
+    values[i][recC[i].len] = '\0';
+  i=C_TEXT;if (values[i] && strlen(values[i]) > recC[i].len)
+    values[i][recC[i].len] = '\0';
+  i=C_EXT;if (values[i] && strlen(values[i]) > recC[i].len)
+    values[i][recC[i].len] = '\0';
+
+  dtaus_prepareC (buf, values[C_TEXT] != NULL, maxtext);
   for (i=0; i<5; i++) buf[recC[C_TRANS].pos+i] = tmp[i];
   if (values[C_MYBLZ])
-    sprintf (tmp, "%08s", values[C_MYBLZ]);
+    sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_MYBLZ]),8));
   else
-    sprintf (tmp, "%08s", valuesA[A_BLZ]);
+    sprintf (tmp, "%s", padzeroclip (strip_nondigits (valuesA[A_BLZ]),8));
   for (i=0; i<recC[C_MYBLZ].len; i++) buf[5+i] = tmp[i];
   for (i=0; i<recC[C_MYBLZ].len; i++) buf[recC[C_MYBLZ].pos+i] = tmp[i];
-  sprintf (tmp, "%08s", values[C_BLZ]);
+  sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_BLZ]),8));
   for (i=0; i<recC[C_BLZ].len; i++) buf[recC[C_BLZ].pos+i] = tmp[i];
-  sprintf (tmp, "%010s", values[C_KTO]);
+  sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_KTO]),10));
   for (i=0; i<recC[C_KTO].len; i++) buf[recC[C_KTO].pos+i] = tmp[i];
-  sprintf (tmp, "%011s", real2string(values[C_VAL]));
+  sprintf (tmp, "%s", padzeroclip (real2string(values[C_VAL]),11));
   for (i=0; i<recC[C_VAL].len; i++) buf[recC[C_VAL].pos+i] = tmp[i];
   if (values[C_MYKTO])
-    sprintf (tmp, "%010s", values[C_MYKTO]);
+    sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_MYKTO]),10));
   else
-    sprintf (tmp, "%010s", valuesA[A_KTO]);
+    sprintf (tmp, "%s", padzeroclip (strip_nondigits (valuesA[A_KTO]),10));
   for (i=0; i<recC[C_MYKTO].len; i++) buf[recC[C_MYKTO].pos+i] = tmp[i];
   sprintf (tmp, "%-27s", upcase(values[C_NAME]));
   for (i=0; i<recC[C_NAME].len; i++) buf[recC[C_NAME].pos+i] = tmp[i];
@@ -556,18 +636,40 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values)
   sprintf (tmp, "%-27s", upcase(values[C_ZWECK]));
   for (i=0; i<recC[C_ZWECK].len; i++) buf[recC[C_ZWECK].pos+i] = tmp[i];
 
-  if (!values[C_TEXT]) {
-    buf[recC[C_TEXT].pos+0] = ' ';
-    buf[recC[C_TEXT].pos+1] = ' ';
-  } else {
-    buf[185+0] = '0';
-    buf[185+1] = '1';
+  if (values[C_TEXT]) {
     buf[recC[C_TEXT].pos+0] = '0';
     buf[recC[C_TEXT].pos+1] = '2';
     sprintf (tmp, "%-27s", upcase(values[C_TEXT]));
     for (i=0; i<recC[C_TEXT].len-2; i++) buf[recC[C_TEXT].pos+2+i] = tmp[i];
   }
+
+  if (text) {
+    res = div (maxtext, 4);
+    i=res.quot;
+    if (res.rem) i++;
+
+    buf[185+0] = (i/10)+48;i-=(i/10)*10;
+    buf[185+1] = i+48;
+  }
+
   fputs(buf, f);
+
+  if (text) {
+    fieldnr=0;
+    while (fieldnr<maxtext) {
+      memset (appendix, ' ', 128);
+      appendix[128] = '0';
+      for (k=0; k<4 && (fieldnr+k)<maxtext; k++) {
+       sprintf (tmp, "%-27s", upcase(text[fieldnr+k]));
+       appendix[k*29] = '0';
+       appendix[(k*29)+1] = '2';
+       for (i=0; i<recC[C_TEXT].len-2; i++) appendix[(k*29)+2+i] = tmp[i];
+      }
+      fputs(appendix, f);
+      fieldnr += k;
+    }
+  }
+
   return 1;
 }
 
@@ -581,19 +683,30 @@ int dtaus_writeE(FILE *f, int count, bigint sum, bigint blz, bigint kto)
 
   sprintf (tmp, "%07d", count);
   for (i=0; i<recE[E_COUNT].len; i++) buf[recE[E_COUNT].pos+i] = tmp[i];
-  bigint_sprintf (tmp, "%013s", sum);
+  bigint_sprintf (tmp, "%s", sum);
+  padzeroclip (tmp,13);
   for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
-  bigint_sprintf (tmp, "%013s", sum);
+  bigint_sprintf (tmp, "%s", sum);
+  padzeroclip (tmp,13);
   for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
-  bigint_sprintf (tmp, "%017s", kto);
+  bigint_sprintf (tmp, "%s", kto);
+  padzeroclip (tmp,17);
   for (i=0; i<recE[E_KTO].len; i++) buf[recE[E_KTO].pos+i] = tmp[i];
-  bigint_sprintf (tmp, "%017s", blz);
+  bigint_sprintf (tmp, "%s", blz);
+  padzeroclip (tmp,17);
   for (i=0; i<recE[E_BLZ].len; i++) buf[recE[E_BLZ].pos+i] = tmp[i];
 
   fputs(buf, f);
   return 1;
 }
 
+void printctln(FILE *f, char *field, char *value)
+{
+  if (strlen(field) && strlen(value))
+    fprintf(f, "  %s\t%s\n", field, value);
+}
+
+
 /*
  *  Third: Some high level routines
  */
@@ -633,12 +746,16 @@ void dtaus2control (char *cdtaus, char *ccontrol)
       for (index=A_TRANS; index < A_DATE; index++) {
        bufp = buf + recA[index].pos;
        memcpy(tmp, bufp, recA[index].len); tmp[recA[index].len] = '\0';
-       fprintf(fcontrol, "  %s\t%s\n", recA[index].name, strip_zeros(strip_spaces(tmp)));
+       printctln(fcontrol, recA[index].name, strip_zeros(strip_spaces(tmp)));
       }
 
       index = A_DATE; bufp = buf + recA[index].pos;
       memcpy(tmp, bufp, recA[index].len); tmp[recA[index].len] = '\0';
-      fprintf(fcontrol, "  %s\t%s\n", recA[index].name, strip_spaces(tmp));
+      printctln(fcontrol, recA[index].name, strip_spaces(tmp));
+
+      index = A_EURO; bufp = buf + recA[index].pos;
+      memcpy(tmp, bufp, recA[index].len); tmp[recA[index].len] = '\0';
+      printctln(fcontrol, recA[index].name, strip_zeros(strip_spaces(tmp)));
 
       fprintf(fcontrol, "}\n\n");
     } else {
@@ -659,15 +776,15 @@ void dtaus2control (char *cdtaus, char *ccontrol)
       if (dtaus_nextrec(bufp, fdtaus) == 1) {
        fprintf(fcontrol, "{\n");
 
-       for (index=C_NAME; index <= C_MYBLZ; index++) {
+       for (index=C_NAME; index <= C_EURO; index++) {
          bufp = buf + recC[index].pos;
          memcpy(tmp, bufp, recC[index].len); tmp[recC[index].len] = '\0';
          if (index == C_VAL)
-           fprintf(fcontrol, "  %s\t%s\n", recC[index].name, strip_zeros(string2real(tmp)));
+           printctln(fcontrol, recC[index].name, strip_zeros(string2real(tmp)));
          else if (index == C_TRANS)
-           fprintf(fcontrol, "  %s\t%s\n", recC[index].name, string2trans(tmp));
+           printctln(fcontrol, recC[index].name, strip_zeros(string2trans(tmp)));
          else
-           fprintf(fcontrol, "  %s\t%s\n", recC[index].name, strip_zeros(strip_spaces(tmp)));
+           printctln(fcontrol, recC[index].name, strip_zeros(strip_spaces(tmp)));
        }
 
        for (index=C_TEXT; index <= C_EXT; index++) {
@@ -675,7 +792,7 @@ void dtaus2control (char *cdtaus, char *ccontrol)
            bufp = buf + recC[index].pos;
            memcpy(x, bufp, 2); tmp[2] = '\0'; bufp+=2;
            memcpy(tmp, bufp, recC[index].len-2); tmp[recC[index].len-2] = '\0';
-           fprintf(fcontrol, "  %s\t%s\n", string2ext(x), strip_spaces(tmp));
+           printctln(fcontrol, string2ext(x), strip_spaces(tmp));
          }
        }
 
@@ -706,9 +823,9 @@ void dtaus2control (char *cdtaus, char *ccontrol)
        bufp = buf + recE[index].pos;
        memcpy(tmp, bufp, recE[index].len); tmp[recE[index].len] = '\0';
        if (index == E_VAL)
-         fprintf(fcontrol, "  %s\t%s\n", recE[index].name, strip_zeros(string2real(tmp)));
+         printctln(fcontrol, recE[index].name, strip_zeros(string2real(tmp)));
        else
-         fprintf(fcontrol, "  %s\t%s\n", recE[index].name, strip_zeros(tmp));
+         printctln(fcontrol, recE[index].name, strip_zeros(tmp));
       }
 
       fprintf(fcontrol, "}\n");
@@ -735,6 +852,9 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   char *valA[A_LEN], *valC[C_LEN];
   int count;
   bigint sum_val, sum_blz, sum_kto, bi;
+  char **text = NULL;
+  char *cp;
+  int textindex = 0;
 
   if (!cdtaus)
     if (!(fdtaus = fopen("dtaus0.txt", "w")))
@@ -772,13 +892,6 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   control_nextline ((void *)line, 100, fcontrol);
   ident = extract_ident(line);
   if (!strcmp(ident, "begin") && (line[0] == '{')) {
-    fprintf(fbeleg, "\n\n");
-    fprintf(fbeleg, "\n    Begleitzettel\n\n");
-    fprintf(fbeleg, "\n    Belegloser Datentraegeraustausch\n\n");
-    fprintf(fbeleg, "\n    Sammeleinziehungsauftrag\n\n");
-    fprintf(fbeleg, "\n    VOL ........................:\n");
-    fprintf(fbeleg, "\n    Erstellungsdatum ...........: %s\n", get_date());
-
     control_nextline ((void *)line, 100, fcontrol);
     while (strlen(line) && line[0] != '}') {
       ident = extract_ident(line);
@@ -788,6 +901,19 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
            strcpy(valA[recindex], line);
       control_nextline ((void *)line, 100, fcontrol);
     }
+    if (((recindex = rec_index("art", REC_A)) != -1) && valA[recindex] && strlen(valA[recindex])) {
+      fprintf(fbeleg, "\n\n");
+      fprintf(fbeleg, "\n    Begleitzettel\n\n");
+      fprintf(fbeleg, "\n    Belegloser Datentraegeraustausch\n\n");
+      if (valA[recindex][0] == 'L')
+       fprintf(fbeleg, "\n    Sammeleinziehungsauftrag\n\n");
+      else if (valA[recindex][0] == 'G')
+       fprintf(fbeleg, "\n    Sammelueberweisungsauftrag\n\n");
+      else
+       fprintf(fbeleg, "\n    Sammelauftrag\n\n");
+      fprintf(fbeleg, "\n    VOL ........................:\n");
+      fprintf(fbeleg, "\n    Erstellungsdatum ...........: %s\n", get_date());
+    }
     if (!dtaus_writeA(fdtaus, valA)) {
       fprintf (stderr, "Konnte den Anfangsdatensatz nicht schreiben.\n");
       return 0;
@@ -815,15 +941,45 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   if (line[0] == '{') {
     while (strlen(line) && line[0] == '{') {
       control_nextline ((void *)line, 100, fcontrol);
+      if (text) {
+       for (textindex=0; textindex < MAX_TEXT && text[textindex]; textindex++)
+         free (text[textindex]);
+       free (text);
+       text = NULL;
+      }
       while (strlen(line) && line[0] != '}') {
        ident = extract_ident(line);
        if ((recindex = rec_index(ident, REC_C)) != -1)
-         if (recC[recindex].type != IGN)
-           if ((valC[recindex] = (char *)malloc (strlen(line)+1)))
-             strcpy(valC[recindex], line);
+         if (recC[recindex].type != IGN) {
+           /*
+            * Special exception to support multiple Text fields
+            */
+           if (recindex == C_TEXT && valC[recindex]) {
+             if (!text) {
+               if ((text = (char **)malloc ((MAX_TEXT+1) * sizeof (char *))) == NULL)
+                 return 0;
+               else {
+                 textindex = 0;
+                 memset (text, 0, (MAX_TEXT+1) * sizeof (char *));
+               }
+             }
+             if (textindex < MAX_TEXT) {
+               if ((cp = (char *)malloc (strlen (line) + 1))) {
+                 strcpy (cp, line);
+                 cp[strlen (line)] = '\0';
+                 text[textindex++] = cp;
+               }
+             }
+           } else {
+             if ((valC[recindex] = (char *)malloc (strlen(line)+1)))
+               strcpy(valC[recindex], line);
+             else
+               return 0;
+           }
+         }
        control_nextline ((void *)line, 100, fcontrol);
       }
-      if (!dtaus_writeC(fdtaus, valA, valC)) {
+      if (!dtaus_writeC(fdtaus, valA, valC, text)) {
        fprintf (stderr, "Konnte den regulären Datensatz nicht schreiben.\n");
        return 0;
       }