Business-KontoCheck
view release on metacpan or search on metacpan
konto_check.c view on Meta::CPAN
lut_version=3; /* keine alten LUT-Dateien mehr generieren */
ok=LUT_V2_FILE_GENERATED;
}
#endif
if(!slots)slots=DEFAULT_SLOTS;
if(slots<SLOT_CNT_MIN){
slots=SLOT_CNT_MIN; /* Minimalzahl Slots */
ok=OK_SLOT_CNT_MIN_USED;
}
if(!outputname)outputname=(char *)default_lutname[0];
if(stat(inputname,&s_buf)==-1)RETURN(FILE_READ_ERROR);
bufsize=s_buf.st_size+10+strlen(testbanken_neu);
if(!(buffer=(char *)malloc(bufsize)) || !(out_buffer=(char *)malloc(bufsize)))RETURN(ERROR_MALLOC);
if(!(in=fopen(inputname,"rb"))){
PRINT_VERBOSE_DEBUG_FILE("fopen(rb)");
if(buffer)FREE(buffer);
if(out_buffer)FREE(out_buffer);
RETURN(FILE_READ_ERROR);
}
cnt=fread(buffer,1,s_buf.st_size,in);
for(ptr=buffer;*ptr!='\r' && *ptr!='\n';ptr++);
konto_check.c view on Meta::CPAN
have_iban_rules?"":"keine ",
compr_str[compression_lib],
rand()&32767,rand()&32767,rand()&32767,rand()&32767,rand()&32767,rand()&32767,rand()&32767,rand()&32767);
/* die ersten beiden Zeilen sind nur für den Gültigkeitsblock, nicht für den Vorspann */
for(ptr=out_buffer;*ptr++!='\n';);
while(*ptr++!='\n');
ptr++; /* Leerzeile überspringen */
/* falls ein set angegeben ist, die datei aber nicht existiert, eine neue Datei anlegen (set=0) */
if(set>0 && stat(outputname,&s_buf)==-1)set=0;
if(set>0){ /* Blocks an Datei anhängen */
if(!(lut=fopen(outputname,"rb+"))){
PRINT_VERBOSE_DEBUG_FILE("fopen(rb+)");
retval=FILE_WRITE_ERROR;
goto fini;
}
}
else /* neue LUT-Datei erzeugen */
CHECK_RETVAL(create_lutfile_int(outputname,ptr,slots,&lut));
konto_check.c view on Meta::CPAN
/* falls keine LUT-Datei angegeben wurde, die Suchpfade und Defaultnamen durchprobieren */
if(!lut_name || !*lut_name){
for(i=0,k=-1,lut_name=name_buffer;i<lut_name_cnt && k==-1;i++){
for(j=0;j<lut_searchpath_cnt;j++){
#if _WIN32>0
snprintf(lut_name,LUT_PATH_LEN,"%s\\%s",lut_searchpath[j],default_lutname[i]);
#else
snprintf(lut_name,LUT_PATH_LEN,"%s/%s",lut_searchpath[j],default_lutname[i]);
#endif
if(!(k=stat(lut_name,&s_buf)))break;
}
}
if(k==-1)RETURN(NO_LUT_FILE); /* keine Datei gefunden */
}
stat(lut_name,&s_buf);
buflen=s_buf.st_size;
if(!(buffer=(char *)malloc(buflen)))RETURN(ERROR_MALLOC);
if(!(lut=fopen(lut_name,"rb"))){
PRINT_VERBOSE_DEBUG_FILE("fopen(rb)");
FREE(buffer);
RETURN(FILE_READ_ERROR);
}
for(zeile=version=0,ptr=buffer;!feof(lut);){
if(!fgets(ptr,buflen,lut))RETURN(FILE_READ_ERROR); /* LUT-Datei zeilenweise einlesen */
if(!version && !strncmp(buffer,"BLZ Lookup Table/Format 1.0\n",28))version=1;
konto_check.c view on Meta::CPAN
/* falls keine LUT-Datei angegeben wurde, die Suchpfade und Defaultnamen durchprobieren */
if(!lut_name || !*lut_name){
for(j=0,k=-1;j<lut_searchpath_cnt && k==-1;j++){
for(i=0,lut_name=name_buffer;i<lut_name_cnt;i++){
#if _WIN32>0
snprintf(lut_name,LUT_PATH_LEN,"%s\\%s",lut_searchpath[j],default_lutname[i]);
#else
snprintf(lut_name,LUT_PATH_LEN,"%s/%s",lut_searchpath[j],default_lutname[i]);
#endif
if(!(k=stat(lut_name,&s_buf)))break;
}
}
if(k==-1){
init_status=init_in_progress=0;
RETURN(NO_LUT_FILE); /* keine Datei gefunden */
}
}
if(status)*status=lut2_block_status; /* Rückgabe des Statusarrays, falls gewünscht */
/* Info-Block holen und merken */
konto_check.c view on Meta::CPAN
static int read_lut(char *filename,int *cnt_blz)
{
unsigned char *inbuffer,*uptr;
int b,h,k,i,j,prev,cnt,lut_version;
UINT4 adler1,adler2;
struct stat s_buf;
int in;
if(cnt_blz)*cnt_blz=0;
if(!(init_status&1))init_atoi_table();
if(stat(filename,&s_buf)==-1)RETURN(NO_LUT_FILE);
if(!(inbuffer=(unsigned char *)calloc(s_buf.st_size+128,1)))RETURN(ERROR_MALLOC);
if((in=open(filename,O_RDONLY|O_BINARY))<0)RETURN(NO_LUT_FILE);
if(!(cnt=read(in,inbuffer,s_buf.st_size)))RETURN(FILE_READ_ERROR);
close(in);
lut_version= -1;
if(!strncmp((char *)inbuffer,"BLZ Lookup Table/Format 1.0\n",28))
lut_version=1;
if(!strncmp((char *)inbuffer,"BLZ Lookup Table/Format 1.1\n",28))
lut_version=2;
if(lut_version==-1)RETURN(INVALID_LUT_FILE);
konto_check.c view on Meta::CPAN
FILE *out;
struct stat s_buf;
if(!set){ /* set-Parameter 0: BLZ-Datei (Klartext) als Eingabedatei, LUT-Datei generieren */
/* eigene Version von mktemp, da die Libraryversion immer einen Linkerfehler
* erzeugt, der sich nicht deaktivieren läßt (ist hier auch nicht kritisch)
*/
for(i=0;i<100000;i++){
sprintf(tmpfile,"blz_tmp.%05d",i);
if((stat(tmpfile,&s_buf)==-1) && (errno==EBADF || errno==ENOENT))break;
}
lut_set[0]=LUT2_BLZ;
lut_set[1]=LUT2_PZ;
lut_set[2]=LUT2_FILIALEN;
for(i=0;(lut_set[i+3]=lut_set_9[i]) && i<28;i++);
lut_set[i+3]=0;
if(i==100000)return FATAL_ERROR; /* keine mögliche Ausgabedatei gefunden */
ret=generate_lut2(inputname,tmpfile,"Testdatei fuer LUT2",NULL,lut_set,20,3,0);
if(ret<=0){
unlink(tmpfile);
konto_check.c view on Meta::CPAN
/* falls keine LUT-Datei angegeben wurde, die Suchpfade und Defaultnamen durchprobieren */
if(!lut_name || !*lut_name){
for(j=0,k=-1;j<lut_searchpath_cnt && k==-1;j++){
for(i=0,lut_name=name_buffer;i<lut_name_cnt;i++){
#if _WIN32>0
snprintf(lut_name,LUT_PATH_LEN,"%s\\%s",lut_searchpath[j],default_lutname[i]);
#else
snprintf(lut_name,LUT_PATH_LEN,"%s/%s",lut_searchpath[j],default_lutname[i]);
#endif
if(!(k=stat(lut_name,&s_buf)))break;
}
}
if(k==-1)return NO_LUT_FILE; /* keine Datei gefunden */
}
/* Variablen initialisieren */
if((ret=kto_check_clear_default())!=OK)RETURN(ret);
/* Default-Block lesen */
if(!block_id)block_id=LUT2_DEFAULT;
konto_check.c view on Meta::CPAN
DLL_EXPORT int lut_keine_iban_berechnung(char *iban_blacklist,char *lutfile,int set)
{
char *ptr,*ptr1,*dptr,*dptr1,*sptr,*buffer,line[1024];
int *ibuffer,i,size,retval,fertig=0,bufsize;
UINT4 cnt;
FILE *in,*lut;
struct stat sbuf;
if(stat(iban_blacklist,&sbuf))return FILE_READ_ERROR;
if(!(in=fopen(iban_blacklist,"r")))return FILE_READ_ERROR;
if(!(lut=fopen(lutfile,"rb+")))return FILE_WRITE_ERROR;
size=sbuf.st_size;
/* grobe Abschätzung für die Größe des benötigten Arrays: jede BLZ
* benötigt 8 Byte. Der Wert size/8 ist etwas zu hoch, aber auf keinen
* Fall zu klein. Da das Array nur zum Sortieren benötigt und gleich
* wieder freigegeben wird, ist das egal.
*/
if(!(ibuffer=(int *)calloc(size/8,sizeof(int))))return ERROR_MALLOC;
( run in 0.892 second using v1.01-cache-2.11-cpan-bbe5e583499 )