X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fdtaus;a=blobdiff_plain;f=dtaus.c;h=8f16662726e797955b99b453c403a97ae2c39bae;hp=8e1bcf88faf624d65fdf572b9ae41f6cd4a10ae0;hb=6ff6a7fd6838bb2a790c97f5990cd20c0851c611;hpb=7a4a4dbca7f9d0108357b944a26fe6668cc722c6 diff --git a/dtaus.c b/dtaus.c index 8e1bcf8..8f16662 100644 --- a/dtaus.c +++ b/dtaus.c @@ -1,6 +1,6 @@ /* dtaus.c - Datenträgeraustausch mit einer Bank - Copyright (c) 1996 Martin Schulze + Copyright (c) 1996,8 Martin Schulze 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$ */ @@ -54,6 +54,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 +64,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 +77,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 +92,10 @@ 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 dtaus_record recE[] = { {"Anzahl", 10, 7, IGN}, @@ -151,7 +155,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 +183,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; @@ -339,6 +357,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,7 +444,7 @@ 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; } @@ -425,7 +465,7 @@ 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'; @@ -485,14 +525,17 @@ int dtaus_writeA(FILE *f, char **values) 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); @@ -522,6 +565,17 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values) return 0; } + 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); if (!values[C_TEXT]) { buf[1] = '1'; @@ -530,21 +584,21 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values) } 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