#define C_EXT 11
#define C_LEN 12
-#define MAX_TEXT 60
+#define MAX_TEXT 61
dtaus_record recE[] = {
{"Anzahl", 10, 7, IGN},
if (normaltext)
appendix = 1;
if (maxtext) {
- res = div (maxtext, 4);
+ res = div (maxtext-1, 4);
appendix += res.quot;
if (res.rem) appendix++;
}
}
if (text) {
- res = div (maxtext, 4);
+ buf[recC[C_EXT].pos+0] = '0';
+ buf[recC[C_EXT].pos+1] = '2';
+ sprintf (tmp, "%-27s", upcase(text[0]));
+ for (i=0; i<recC[C_EXT].len-2; i++) buf[recC[C_EXT].pos+2+i] = tmp[i];
+
+ res = div (maxtext-1, 4);
i=res.quot;
if (res.rem) i++;
fputs(buf, f);
- if (text) {
- fieldnr=0;
+ if (text && maxtext > 1) {
+ fieldnr=1;
while (fieldnr<maxtext) {
memset (appendix, ' ', 128);
- appendix[128] = '0';
+ appendix[128] = '\0';
for (k=0; k<4 && (fieldnr+k)<maxtext; k++) {
sprintf (tmp, "%-27s", upcase(text[fieldnr+k]));
appendix[k*29] = '0';
void *bufp;
char tmp[30];
char x[30];
- int index, countC;
+ int index;
+ int extC;
- if (!cdtaus)
+ if (!cdtaus) {
if (!(fdtaus = fopen("DTAUS0.TXT", "r")))
if (!(fdtaus = fopen("dtaus0.txt", "r")))
return;
- if (cdtaus)
- if (!(fdtaus = fopen(cdtaus, "r")))
- return;
- if (!ccontrol)
+ } else {
+ if (!strcmp (cdtaus, "-"))
+ fdtaus = stdin;
+ else
+ if (!(fdtaus = fopen(cdtaus, "r")))
+ return;
+ }
+ if (!ccontrol)
fcontrol = stdout;
else
- if (!(fcontrol = fopen(ccontrol, "w")))
- return;
+ if (!strcmp (ccontrol, "-"))
+ fcontrol = stdout;
+ else
+ if (!(fcontrol = fopen(ccontrol, "w")))
+ return;
if (!(buf = (char *)malloc (512)))
return;
if (dtaus_nextrec(buf, fdtaus) == 1) {
while (dtaus_char(buf,4) == 'C') {
bufp = buf + 128;
- if (dtaus_nextrec(bufp, fdtaus) == 1) {
+ if (dtaus_nextrec(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++) {
}
}
- countC = dtaus_int(buf, 185, 2);
- countC = countC<3?0:countC-2/4;
- countC += countC%4>0?1:0;
- /* FIXME: Erweiterungsfelder werden ignoriert */
+ /* Number of extension records for this C record */
+ extC = dtaus_int(buf, 185, 2);
- fprintf(fcontrol, "}\n");
- } else {
- fprintf (stderr, "Der zweite Teil der Transaktion ist kaputt.\n");
- return;
}
if (dtaus_nextrec(buf, fdtaus) != 1)
bzero (buf, sizeof(buf));
+
+ /*
+ * Are there extension records that we have to check?
+ *
+ * 2nd half of the AND is wrong, but since dtaus < 0.5 wrote 01
+ * instead of 00 we should let it in so it can read its own
+ * old files... *sigh*
+ */
+ while (extC > 0 && dtaus_char(buf,4) != 'C' && dtaus_char(buf,4) != 'E') {
+ for (index=0; index < 4; index++) {
+ if ((dtaus_char(buf,index*29) != ' ')) {
+ bufp = buf + index*29;
+ memcpy(x, bufp, 2); tmp[2] = '\0'; bufp+=2;
+ memcpy(tmp, bufp, recC[C_TEXT].len-2); tmp[recC[C_TEXT].len-2] = '\0';
+ printctln(fcontrol, string2ext(x), strip_spaces(tmp));
+ }
+ }
+ if (dtaus_nextrec(buf, fdtaus) != 1)
+ bzero (buf, sizeof(buf));
+ extC--;
+ }
+ fprintf(fcontrol, "}\n");
}
}
*/
if (dtaus_char(buf,4) == 'E') {
if (dtaus_char(buf,4) == 'E') {
- fprintf(fcontrol, "END {\n");
+ fprintf(fcontrol, "\nEND {\n");
for (index=E_COUNT; index <= E_BLZ; index++) {
bufp = buf + recE[index].pos;
char *cp;
int textindex = 0;
- if (!cdtaus)
+ if (!cdtaus) {
if (!(fdtaus = fopen("dtaus0.txt", "w")))
return 0;
- if (cdtaus)
- if (!(fdtaus = fopen(cdtaus, "w")))
- return 0;
- if (!ccontrol)
+ } else {
+ if (!strcmp (cdtaus, "-"))
+ fdtaus = stdout;
+ else
+ if (!(fdtaus = fopen(cdtaus, "w")))
+ return 0;
+ }
+ if (!ccontrol) {
if (!(fcontrol = fopen("dtaus0.ctl", "r")))
if (!(fcontrol = fopen("DTAUS0.CTL", "r")))
return 0;
- if (ccontrol)
- if (!(fcontrol = fopen(ccontrol, "r")))
- return 0;
- if (!cbeleg)
+ } else {
+ if (!strcmp (ccontrol, "-"))
+ fcontrol = stdin;
+ else
+ if (!(fcontrol = fopen(ccontrol, "r")))
+ return 0;
+ }
+ if (!cbeleg) {
if (!(fbeleg = fopen("dtaus0.doc", "w")))
return 0;
- if (cbeleg)
+ } else {
if (!(fbeleg = fopen(cbeleg, "w")))
return 0;
+ }
if (!ccheck)
fcheck = stdout;
else
fprintf(fbeleg, "\n Sammelauftrag\n\n");
fprintf(fbeleg, "\n VOL ........................:\n");
fprintf(fbeleg, "\n Erstellungsdatum ...........: %s\n", get_date());
+ fprintf(fbeleg, "\n Waehrung ...................: DM\n");
}
if (!dtaus_writeA(fdtaus, valA)) {
fprintf (stderr, "Konnte den Anfangsdatensatz nicht schreiben.\n");
}
fprintf (fcheck, "\n\n\n");
- fprintf (fcheck, " Sammeleinzeiehungsauftrag\n\n");
- fprintf (fcheck, " Erstellungsdatum : %s\n\n\n", get_date());
+ if (valA[recindex][0] == 'L')
+ fprintf (fcheck, " Sammeleinzeiehungsauftrag\n\n");
+ else if (valA[recindex][0] == 'G')
+ fprintf (fcheck, " Sammelueberweisungsauftrag\n\n");
+ else
+ fprintf (fcheck, " Sammelauftrag\n\n");
+ fprintf (fcheck, " Erstellungsdatum : %s\n\n", get_date());
+ fprintf (fcheck, " Waehrung : DM\n\n\n");
fprintf (fcheck, " %-10s %-8s %-30s %12s\n", "Kontonr.", "BLZ", "Name", "Betrag");
fprintf (fcheck, " --------------------------------------------------------------------\n");
} else {