From: Joey Schulze Date: Fri, 3 Jul 1998 14:51:14 +0000 (+0000) Subject: . Added hook/theoretical support for Euro X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fdtaus;a=commitdiff_plain;h=a5ee19a2b183e156561de83198b8031dc812b578 . Added hook/theoretical support for Euro . Fixed bug with overflowing tempory variable, this resultsin some correct tests for . Moved routine for printing values if they are set into an own function --- diff --git a/dtaus.c b/dtaus.c index e79f31b..afa151b 100644 --- a/dtaus.c +++ b/dtaus.c @@ -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}, @@ -485,6 +489,9 @@ 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]; @@ -522,6 +529,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'; @@ -594,6 +612,13 @@ int dtaus_writeE(FILE *f, int count, bigint sum, bigint blz, bigint kto) 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 +658,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 +688,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 +704,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 +735,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"); @@ -821,6 +850,8 @@ int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck) if (recC[recindex].type != IGN) 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)) {