Use preprocessor defines for default filenames, so that they won't be
[infodrom/dtaus] / dtaus.c
diff --git a/dtaus.c b/dtaus.c
index e19732d..bfb2dfb 100644 (file)
--- a/dtaus.c
+++ b/dtaus.c
@@ -1,6 +1,6 @@
 /*
     dtaus.c - Belegloser Datenträgeraustausch mit einer Bank
-    Copyright (c) 1996,8,2001  Martin Schulze <joey@infodrom.org>
+    Copyright (c) 1996,8,2001-4  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
 #include <time.h>
 #include <malloc.h>
 
-/* #define DEFAULT_EURO */
+#define DEFAULT_EURO
 #ifndef DEFAULT_EURO
 int use_euro = 0;
+#else
+int use_euro = 1;
 #endif
 
 /*
@@ -61,7 +63,9 @@ dtaus_record recA[] = {
   {"Referenz", 70, 10, OPT},
   {"Datum", 50, 6, IGN},
   {"Ausfuehrung", 95, 8, OPT},
+  {"Currency", 127, 1, OPT},
   {"Euro", 127, 1, OPT},
+  {"DM", 127, 1, OPT},
   {NULL, 0, 0}
 };
 
@@ -72,8 +76,11 @@ dtaus_record recA[] = {
 #define A_REF  4
 #define A_DATE 5
 #define A_TODO 6
-#define A_EURO 7
-#define A_LEN  8
+#define A_CURR 7
+#define A_EURO 8
+#define A_DM   9
+#define A_LEN  10
+#define A_LOOP 7
 
 dtaus_record recC[] = {
   {"Name", 93, 27, REQ},
@@ -89,11 +96,13 @@ 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},
+  {"Currency", 182, 1, IGN},
 #ifndef DEFAULT_EURO
   {"Betrag-Euro", 79, 11, IGN},
+#else
+  {"Betrag-DM", 50, 11, IGN},
 #endif
   {NULL, 0, 0}
 };
@@ -107,15 +116,16 @@ dtaus_record recC[] = {
 #define C_MYNAM        6
 #define C_MYKTO        7
 #define C_MYBLZ        8
-#define C_EURO  9
-#define C_TEXT 10
-#define C_EXT  11
+#define C_TEXT  9
+#define C_EXT  10
+#define C_EURO 11
 #ifndef DEFAULT_EURO
 #define C_EUR  12
-#define C_LEN  13
 #else
-#define C_LEN  12
+#define C_DM   12
 #endif
+#define C_LEN  13
+#define C_LOOP 11
 
 #define MAX_TEXT 14
 
@@ -130,6 +140,8 @@ dtaus_record recE[] = {
   {"BLZs", 47, 17, IGN},
 #ifndef DEFAULT_EURO
   {"Summe-Euro", 64, 13, IGN},
+#else
+  {"Summe-DM", 17, 13, IGN},
 #endif
   {NULL, 0, 0}
 };
@@ -140,7 +152,10 @@ dtaus_record recE[] = {
 #define E_BLZ  3
 #ifndef DEFAULT_EURO
 #define E_EUR  4
+#else
+#define E_DM   4
 #endif
+#define E_LEN  5
 
 /*
  *  Second: Some low level routines
@@ -148,7 +163,7 @@ dtaus_record recE[] = {
 
 size_t dtaus_nextrec (void **buf, FILE *f)
 {
-  bzero (buf, 128);
+  memset (buf, 0, 128);
   return fread(buf, 128, 1, f);
 }
 
@@ -234,7 +249,7 @@ char *strip_nondigits (char *s)
 char dtaus_char (void *buf, unsigned int pos)
 {
   static char res;
-  char *bufp = buf;
+  char *bufp = (char *)buf;
 
   bufp+=pos;
   memcpy(&res, bufp, 1);
@@ -258,15 +273,57 @@ char *real2string(char *s)
 {
   static char res[20];
   char *cp;
+  char *xp;    /* only to avoid a GCC warning */
 
-  strcpy(res, s);
+  strncpy(res, s, sizeof(res)-1);
+  res[sizeof(res)-1] = 0;
   for (cp=res; *cp&&!(*cp == ',')&&!(*cp == '.');cp++);
-  *(cp++) = *(cp+1);
-  *(cp++) = *(cp+1);
+
+  if ((cp-res) >= (sizeof(res)-3)) { 
+    /* Bail out, since the number is too large, shouldn't be possible though. */
+    fprintf (stderr, "Value %s too large.\n", res);
+    exit (1);
+  }
+
+  if (*cp == '.' || *cp == ',') {
+    if (*(cp+1)) {
+      /* 1st decimal place */
+      xp = cp+1;
+      if (*xp && isdigit(*xp))
+       *(cp++) = *xp;
+      else
+       *(cp++) = '0';
+      /* 2nd decimal place */
+      xp = cp+1;
+      if (*xp && isdigit(*xp))
+       *(cp++) = *xp;
+      else
+       *(cp++) = '0';
+    } else {
+      *(cp++) = '0';
+      *(cp++) = '0';
+    }
+  } else {
+    *(cp++) = '0';
+    *(cp++) = '0';
+  }
   *cp = '\0';
   return res;
 }
 
+/*
+ * Return the last digit of the year as character
+ */
+char get_date_lastdigit()
+{
+  time_t timer;
+  struct tm *loctime;
+
+  timer = time ( NULL );
+  loctime = localtime(&timer);
+  return loctime->tm_year % 10 + '0';
+}
+
 char *string2trans (char *s)
 {
   static char res[30];
@@ -285,7 +342,7 @@ char *string2trans (char *s)
   else if (!strcmp(s, "53000"))
     sprintf (res, "Lohn");
   else if (!strncmp(s, "5400", 4))
-    sprintf (res, "Vermögen");
+    sprintf (res, "Vermögen %c",s[4]);
   /*  else if (!strcmp(s, "56000"))
     sprintf (res, ""); / * Überweisung öffentlicher Kassen */
   return res;
@@ -294,6 +351,7 @@ char *string2trans (char *s)
 char *trans2string (char *s)
 {
   static char res[30];
+  char *cp;
 
   res[0] = '\0';
   if (!strcmp(s, "Abbuchung"))
@@ -308,8 +366,34 @@ char *trans2string (char *s)
     sprintf (res, "51000");
   else if (!strcmp(s, "Lohn"))
     sprintf (res, "53000");
-  else if (!strncmp(s, "Vermögen", 4))
-    sprintf (res, "5400");
+  else {
+    cp = NULL;
+    if (!strncmp(s, "Vermögen", 8))
+      cp = s+8;
+    if (!strncmp(s, "Vermoegen", 9))
+      cp = s+9;
+
+    if (!cp) {
+      fprintf (stderr, "Unbekannte Transaktion `%s'\n", res);
+      exit (1);
+    }
+
+    /*
+      Vermögen --> 5400<heutiges Jahr>
+      Vermögen 8 -> 5400<8>
+      Vermögen 2003 -> 5400<3>
+     */
+
+    if (*cp) while (!isspace(*cp)) cp++;
+    while (isspace(*cp)) cp++;
+
+    if (!*cp || !isdigit(*cp))
+      sprintf (res, "5400%c",get_date_lastdigit());
+    else {
+      while (isdigit(*cp)) cp++;
+      sprintf (res, "5400%c",*(cp-1));
+    }
+  }
   /*  else if (!strcmp(s, ""))
     sprintf (res, "56000"); / * Überweisung öffentlicher Kassen */
   return res;
@@ -346,7 +430,7 @@ char *ext2string (char *s)
 unsigned long int dtaus_int(void *buf, unsigned int pos, unsigned int len)
 {
   char tmp[30];
-  char *bufp = buf;
+  char *bufp = (char *)buf;
   static unsigned long int res;
 
   bufp+=pos;
@@ -366,8 +450,8 @@ char *extract_ident (char *line)
   static char word[30];
 
   if (strlen(line) > 0) {
-    x = index (line, ' ');
-    y = index (line, '\t');
+    x = strchr (line, ' ');
+    y = strchr (line, '\t');
 
     if (!x && !y) {
         strncpy(word, line, 29);
@@ -440,8 +524,8 @@ size_t control_nextline (void **buf, int len, FILE *f)
   char *cp;
   int i;
 
-  bzero (line, sizeof(line));
-  bzero (buf, len);
+  memset (line, 0, sizeof(line));
+  memset (buf, 0, len);
   cp = line;
 
   while (!strlen(line) && (cp = fgets(line, 100, f))) {
@@ -452,7 +536,7 @@ size_t control_nextline (void **buf, int len, FILE *f)
          while (tmp[strlen(tmp)-1] != '\n' && (cp = fgets(tmp, 100, f)));
        } else
          line[strlen(line)-1] = '\0';
-       if (line[strlen(line)-1] == '\r')
+       if (line[strlen(line)-1] == '\r')
          line[strlen(line)-1] = '\0';
        for (i=strlen(line);(line[i-1] == ' '||line[i-1] == '\t')&&i>0; i--)
          line[i-1] = '\0';
@@ -471,6 +555,9 @@ size_t control_nextline (void **buf, int len, FILE *f)
     return 0;
 }
 
+/*
+ * Return the current date nicely formatted
+ */
 char *get_date()
 {
   static char res[10];
@@ -494,7 +581,7 @@ void dtaus_prepareA (char *buf)
   struct tm *loctime;
   char tmp[10];
 
-  bzero (buf, 129);
+  memset (buf, 0, 129);
   timer = time ( NULL );
   loctime = localtime(&timer);
 
@@ -509,14 +596,10 @@ void dtaus_prepareA (char *buf)
   for (i=56;i<56+4; i++) buf[i] = ' ';         /* A8 */
   for (i=70;i<70+10; i++) buf[i] = '0';                /* A10 */
   for (i=80;i<80+48; i++) buf[i] = ' ';                /* A11 */
-#ifdef DEFAULT_EURO
-  buf[recA[A_EURO].pos] = '1';                         /* A12 (Currency) */
-#else
   if (use_euro)
-    buf[recA[A_EURO].pos] = '1';                               /* A12 (Currency) */
+    buf[recA[A_CURR].pos] = '1';                               /* A12 (Currency) */
   else
-    buf[recA[A_EURO].pos] = ' ';                               /* A12 (Currency) */
-#endif
+    buf[recA[A_CURR].pos] = ' ';                               /* A12 (Currency) */
 }
 
 /*
@@ -528,7 +611,7 @@ void dtaus_prepareC (char *buf, int normaltext, int maxtext)
   int i;
   int appendix = 0;
 
-  bzero (buf, 257);
+  memset (buf, 0, 257);
 
   if (normaltext)
     appendix = 1;
@@ -552,14 +635,10 @@ void dtaus_prepareC (char *buf, int normaltext, int maxtext)
   for (i=90;i<90+3; i++) buf[i] = ' ';         /* C13 */
   for (i=93;i<90+27; i++) buf[i] = ' ';                /* C14a (Kunde) */
   for (i=120;i<120+8; i++) buf[i] = ' ';       /* C14b */
-#ifdef DEFAULT_EURO
-  buf[recC[C_EURO].pos] = '1';                         /* C17a (Currency) */
-#else
   if (use_euro)
     buf[recC[C_EURO].pos] = '1';                               /* C17a (Currency) */
   else
     buf[recC[C_EURO].pos] = ' ';                               /* C17a (Currency) */
-#endif
   for (i=183;i<183+2; i++) buf[i] = ' ';       /* C17b */
   for (i=187;i<187+(29*2); i++) buf[i] = ' ';  /* C19-C22 (misc text) */
   for (i=245;i<245+11; i++) buf[i] = ' ';      /* C23 */
@@ -576,7 +655,7 @@ void dtaus_prepareE (char *buf)
 {
   int i;
 
-  bzero (buf, 129);
+  memset (buf, 0, 129);
   buf[0] = '0';
   buf[1] = '1';
   buf[2] = '2';
@@ -651,7 +730,7 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values, char **text)
     }
   sprintf (tmp, "%s", trans2string(values[C_TRANS]));
   if (!strlen(tmp)) {
-    fprintf (stderr, "Ungültiger Typ, nur Abbuchung, Einzug, E-Cash, E-Cash-A, Gutschrift und Lohn erlaubt.\n");
+    fprintf (stderr, "Ungültige Transaktion, nur Abbuchung, Einzug, E-Cash, E-Cash-A, Gutschrift und Lohn erlaubt.\n");
     return 0;
   }
 
@@ -683,7 +762,10 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values, char **text)
   else
     for (i=0; i<recC[C_EUR].len; i++) buf[recC[C_EUR].pos+i] = tmp[i];
 #else
-  for (i=0; i<recC[C_VAL].len; i++) buf[recC[C_VAL].pos+i] = tmp[i];
+  if (use_euro)
+    for (i=0; i<recC[C_VAL].len; i++) buf[recC[C_VAL].pos+i] = tmp[i];
+  else
+    for (i=0; i<recC[C_DM].len; i++) buf[recC[C_DM].pos+i] = tmp[i];
 #endif
   if (values[C_MYKTO])
     sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_MYKTO]),10));
@@ -753,7 +835,10 @@ int dtaus_writeE(FILE *f, int count, bigint sum, bigint blz, bigint kto)
   else
     for (i=0; i<recE[E_EUR].len; i++) buf[recE[E_EUR].pos+i] = tmp[i];
 #else
-  for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
+  if (use_euro)
+    for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
+  else
+    for (i=0; i<recE[E_DM].len; i++) buf[recE[E_DM].pos+i] = tmp[i];
 #endif
   bigint_sprintf (tmp, "%s", kto);
   padzeroclip (tmp,17);
@@ -772,6 +857,50 @@ void printctln(FILE *f, char *field, char *value)
     fprintf(f, "  %s\t%s\n", field, value);
 }
 
+/*
+ * one date line, format it properly
+ */
+void printctlndate(FILE *f, char *field, char *value)
+{
+  char mydate[11];
+  int i;
+
+  if (!strlen(field) || !strlen(value))
+    return;
+
+  for (i=0;isspace (value[i]) && i<= strlen (value); i++);
+  if (i == strlen (value))
+    return;
+
+  memset (mydate, 0, sizeof (mydate));
+  if (strlen (value) == 6) {
+    mydate[0] = value[0];
+    mydate[1] = value[1];
+    mydate[2] = '.';
+    mydate[3] = value[2];
+    mydate[4] = value[3];
+    mydate[5] = '.';
+    mydate[6] = value[4];
+    mydate[7] = value[5];
+    fprintf(f, "  %s\t%s\n", field, mydate);
+  } else if (strlen (value) == 8) {
+    mydate[0] = value[0];
+    mydate[1] = value[1];
+    mydate[2] = '.';
+    mydate[3] = value[2];
+    mydate[4] = value[3];
+    mydate[5] = '.';
+    mydate[6] = value[4];
+    mydate[7] = value[5];
+    mydate[8] = value[6];
+    mydate[9] = value[7];
+    fprintf(f, "  %s\t%s\n", field, mydate);
+  } else {
+    fprintf (stderr, "Broken date field: %s\n", value);
+    fprintf(f, "  %s\t%s\n", field, value);
+  }
+}
+
 
 /*
  *  Third: Some high level routines
@@ -780,8 +909,8 @@ void printctln(FILE *f, char *field, char *value)
 void dtaus2control (char *cdtaus, char *ccontrol)
 {
   FILE *fdtaus, *fcontrol;
-  void *buf;
-  void *bufp;
+  char *buf;
+  char *bufp;
   char tmp[30];
   char x[30];
   int index;
@@ -813,25 +942,28 @@ void dtaus2control (char *cdtaus, char *ccontrol)
   /* 
    * Record A lesen
    */
-  if (dtaus_nextrec(buf, fdtaus) == 1) {
+  if (dtaus_nextrec((void *)buf, fdtaus) == 1) {
     if (dtaus_char(buf,4) == 'A') {
       fprintf(fcontrol, "BEGIN {\n");
       bufp = buf;
 
-#ifndef DEFAULT_EURO
-      for (index=A_TRANS; index <= A_EURO; index++) {
-#else
-      for (index=A_TRANS; index < A_EURO; index++) {
-#endif
+      for (index=A_TRANS; index < A_LOOP; index++) {
        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)));
+       if (index == A_DATE || index == A_TODO)
+         printctlndate(fcontrol, recA[index].name, tmp);
+       else
+         printctln(fcontrol, recA[index].name, strip_zeros(strip_spaces(tmp)));
       }
 
-#ifndef DEFAULT_EURO
-      if (tmp[recA[index].pos] == '1')
+      bufp = buf + recA[A_CURR].pos;
+      if (*bufp == '1') {
        use_euro = 1;
-#endif
+       fprintf(fcontrol, "  Euro\n");
+      } else {
+       use_euro = 0;
+       fprintf(fcontrol, "  DM\n");
+      }
 
       fprintf(fcontrol, "}\n\n");
     } else {
@@ -846,27 +978,38 @@ void dtaus2control (char *cdtaus, char *ccontrol)
   /*
    * Record C lesen
    */
-  if (dtaus_nextrec(buf, fdtaus) == 1) {
+  if (dtaus_nextrec((void *)buf, fdtaus) == 1) {
     while (dtaus_char(buf,4) == 'C') {
       bufp = buf + 128;
-      if (dtaus_nextrec(bufp, fdtaus) != 1) {
+      if (dtaus_nextrec((void *)bufp, fdtaus) != 1) {
        fprintf (stderr, "Der zweite Teil der Transaktion ist kaputt.\n");
        return;
       } else {
        fprintf(fcontrol, "{\n");
 
-       for (index=C_NAME; index < C_EURO; index++) {
+       for (index=C_NAME; index < C_LOOP; index++) {
 #ifndef DEFAULT_EURO
          if (use_euro && index == C_VAL)
            index = C_EUR;
+#else
+         if (!use_euro && index == C_VAL)
+           index = C_DM;
 #endif
          bufp = buf + recC[index].pos;
          memcpy(tmp, bufp, recC[index].len); tmp[recC[index].len] = '\0';
+
+         /*
+          * C_EUR and C_DM are outside of the loop, can only be
+          * selected for the non-default currency, but the value
+          * should be stored in the normal record field.
+          */
 #ifndef DEFAULT_EURO
-         if (index == C_VAL || index == C_EUR)
+         if (index == C_EUR)
 #else
-         if (index == C_VAL)
+         if (index == C_DM)
 #endif
+           printctln(fcontrol, recC[C_VAL].name, strip_zeros(string2real(tmp)));
+         else if (index == C_VAL)
            printctln(fcontrol, recC[index].name, strip_zeros(string2real(tmp)));
          else if (index == C_TRANS)
            printctln(fcontrol, recC[index].name, strip_zeros(string2trans(tmp)));
@@ -875,6 +1018,9 @@ void dtaus2control (char *cdtaus, char *ccontrol)
 #ifndef DEFAULT_EURO
          if (use_euro && index == C_EUR)
            index = C_VAL;
+#else
+         if (!use_euro && index == C_DM)
+           index = C_VAL;
 #endif
        }
 
@@ -896,8 +1042,8 @@ void dtaus2control (char *cdtaus, char *ccontrol)
          if (res.rem) extC++;
        }
       }
-      if (dtaus_nextrec(buf, fdtaus) != 1)
-       bzero (buf, sizeof(buf));
+      if (dtaus_nextrec((void *)buf, fdtaus) != 1)
+       memset (buf, 0, sizeof(buf));
 
       /*
        * Are there extension records that we have to check?
@@ -915,8 +1061,8 @@ void dtaus2control (char *cdtaus, char *ccontrol)
            printctln(fcontrol, string2ext(x), strip_spaces(tmp));
          }
        }
-       if (dtaus_nextrec(buf, fdtaus) != 1)
-         bzero (buf, sizeof(buf));
+       if (dtaus_nextrec((void *)buf, fdtaus) != 1)
+         memset (buf, 0, sizeof(buf));
        extC--;
       }
       fprintf(fcontrol, "}\n");
@@ -935,20 +1081,28 @@ void dtaus2control (char *cdtaus, char *ccontrol)
 #ifndef DEFAULT_EURO
        if (use_euro && index == E_VAL)
          index = E_EUR;
+#else
+       if (!use_euro && index == E_VAL)
+         index = E_DM;
 #endif
+
        bufp = buf + recE[index].pos;
        memcpy(tmp, bufp, recE[index].len); tmp[recE[index].len] = '\0';
+
 #ifndef DEFAULT_EURO
        if (index == E_VAL || index == E_EUR)
 #else
-       if (index == E_VAL)
+       if (index == E_VAL || index == E_DM)
 #endif
-         printctln(fcontrol, recE[index].name, strip_zeros(string2real(tmp)));
+         printctln(fcontrol, recE[E_VAL].name, strip_zeros(string2real(tmp)));
        else
          printctln(fcontrol, recE[index].name, strip_zeros(tmp));
 #ifndef DEFAULT_EURO
          if (use_euro && index == E_EUR)
            index = E_VAL;
+#else
+         if (!use_euro && index == E_DM)
+           index = E_VAL;
 #endif
       }
 
@@ -979,6 +1133,7 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   char **text = NULL;
   char *cp;
   int textindex = 0;
+  int len, i;
 
   if (!cdtaus) {
     if (!(fdtaus = fopen("dtaus0.txt", "w")))
@@ -1021,7 +1176,7 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   /* 
    * Record A lesen
    */
-  bzero(valA, sizeof(valA));
+  memset (valA, 0, sizeof(valA));
   control_nextline ((void *)line, 100, fcontrol);
   ident = extract_ident(line);
   if (!strcmp(ident, "begin") && (line[0] == '{')) {
@@ -1029,18 +1184,16 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
     while (strlen(line) && line[0] != '}') {
       ident = extract_ident(line);
       if ((recindex = rec_index(ident, REC_A)) != -1)
-#ifndef DEFAULT_EURO
        {
-#endif
        if (recA[recindex].type != IGN)
          if ((valA[recindex] = (char *)malloc (strlen(line)+1)))
            strcpy(valA[recindex], line);
-#ifndef DEFAULT_EURO
        } else {
          if (! strcasecmp (ident, "euro"))
            use_euro = 1;
+         if (! strcasecmp (ident, "dm"))
+           use_euro = 0;
        }
-#endif
       control_nextline ((void *)line, 100, fcontrol);
     }
     if (((recindex = rec_index("art", REC_A)) != -1) && valA[recindex] && strlen(valA[recindex])) {
@@ -1056,16 +1209,12 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
       fprintf(fbeleg, "\n    VOL ........................:\n");
       fprintf(fbeleg, "\n    Erstellungsdatum ...........: %s\n", get_date());
       if (valA[A_TODO]) {
-       fprintf(fbeleg, "\n    Ausfuehrugsdatum ...........: %s\n", valA[A_TODO]);
+       fprintf(fbeleg, "\n    Ausfuehrungsdatum ..........: %s\n", valA[A_TODO]);
       }
-#ifndef DEFAULT_EURO
       if (use_euro)
        fprintf(fbeleg, "\n    Waehrung ...................: Euro\n");
       else
        fprintf(fbeleg, "\n    Waehrung ...................: DM\n");
-#else
-      fprintf(fbeleg, "\n    Waehrung ...................: Euro\n");
-#endif
     }
     if (!dtaus_writeA(fdtaus, valA)) {
       fprintf (stderr, "Konnte den Anfangsdatensatz nicht schreiben.\n");
@@ -1080,14 +1229,10 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
     else
       fprintf (fcheck, "    Sammelauftrag\n\n");
     fprintf (fcheck, "    Erstellungsdatum : %s\n\n", get_date());
-#ifndef DEFAULT_EURO
     if (use_euro)
       fprintf (fcheck, "    Waehrung         : Euro\n\n\n");
     else
       fprintf (fcheck, "    Waehrung         : DM\n\n\n");
-#else
-    fprintf (fcheck, "    Waehrung         : Euro\n\n\n");
-#endif
     fprintf (fcheck, "     %-10s  %-8s  %-30s   %12s\n", "Kontonr.", "BLZ", "Name", "Betrag");
     fprintf (fcheck, "    --------------------------------------------------------------------\n");
   } else {
@@ -1102,7 +1247,7 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
   sum_val = bigint_int(0);
   sum_blz = bigint_int(0);
   sum_kto = bigint_int(0);
-  bzero(valC, sizeof(valC));
+  memset (valC, 0, sizeof(valC));
   control_nextline ((void *)line, 100, fcontrol);
   if (line[0] == '{') {
     while (strlen(line) && line[0] == '{') {
@@ -1137,10 +1282,31 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
                }
              }
            } else {
-             if ((valC[recindex] = (char *)malloc (strlen(line)+1)))
-               strcpy(valC[recindex], line);
-             else
-               return 0;
+             len = strlen(line);
+             if (recindex == C_VAL) {
+               /* Convert commast to dots for later processing */
+               for (i=0; line[i]; i++) if (line[i] == ',') line[i] = '.';
+
+               if ((cp = index (line, '.')) == NULL) {
+                 if (!(valC[recindex] = (char *)malloc (strlen(line)+4)))
+                   return 0;
+                 sprintf (valC[recindex], "%s.00", line);
+               } else if ( ((len = cp - line + 3)) < strlen (line)) {
+                 if (!(valC[recindex] = (char *)malloc (len+1)))
+                    return 0;
+                  strncpy (valC[recindex], line, len);
+                 valC[recindex][len] = '\0';
+               } else {
+                  if (!(valC[recindex] = (char *)malloc (strlen(line)+1)))
+                    return 0;
+                 strcpy(valC[recindex], line);
+               }
+             } else {
+               if ((valC[recindex] = (char *)malloc (strlen(line)+1)))
+                 strcpy(valC[recindex], line);
+               else
+                 return 0;
+             }
            }
          }
        control_nextline ((void *)line, 100, fcontrol);
@@ -1158,7 +1324,7 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck)
       for (recindex=0; recindex<C_LEN; recindex++)
        if (valC[recindex])
          free(valC[recindex]);
-      bzero(valC, sizeof(valC));
+      memset (valC, 0, sizeof(valC));
       control_nextline ((void *)line, 100, fcontrol);
     }
   } else {