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;
konto_check.c view on Meta::CPAN
z.tm_hour=6; /* Die SCL-Datei wird um 6 Uhr morgens veröffentlicht */
z.tm_mday=tag;
z.tm_mon=monat;
z.tm_year=jahr-1900;
ts=mktime(&z);
snprintf(scl_gueltigkeit_iso,16,"%4d-%02d-%02d",jahr%10000,monat%100,tag%100);
if(!fgets(buffer,512,in))RETURN(SCL_INPUT_FORMAT_ERROR);
/* Leerzeichen aus dem Überschrift-String entfernen */
for(ptr=buffer,ptr2=buffer2;*ptr;ptr++)if(!isspace(*ptr))*ptr2++=*ptr;
if(strncmp(buffer2,"BIC;Name;SERVICESCT;SERVICECOR;SERVICECOR1;SERVICEB2B;SERVICESCC",64))RETURN(SCL_INPUT_FORMAT_ERROR);
stat(inputfile,&stat_buffer);
cnt=stat_buffer.st_size/163+300; /* etwas großzügig die Anzahl rechnen; jede Zeile hat 163 Bytes und ist am Ende mit Leerzeichen aufgefüllt */
scl_bic_array=(char **)calloc(sizeof(char*),cnt);
scl_name_array=(char **)calloc(sizeof(char*),cnt);
scl_flags_array=(char **)calloc(sizeof(char*),cnt);
scl_flags_array_o=(char **)calloc(sizeof(char*),cnt);
scl_bic_block=ptr1=(char *)calloc(12,cnt);
scl_name_block=ptr2=(char *)calloc(150,cnt);
zlib/contrib/minizip/minizip.c view on Meta::CPAN
}
#else
#if defined(unix) || defined(__APPLE__)
static int filetime(f, tmzip, dt)
const char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
(void)dt;
int ret=0;
struct stat s; /* results of stat() */
struct tm* filedate;
time_t tm_t=0;
if (strcmp(f,"-")!=0)
{
char name[MAXFILENAME+1];
size_t len = strlen(f);
if (len > MAXFILENAME)
len = MAXFILENAME;
strncpy(name, f,MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */
name[ MAXFILENAME ] = '\0';
if (name[len - 1] == '/')
name[len - 1] = '\0';
/* not all systems allow stat'ing a file with / appended */
if (stat(name,&s)==0)
{
tm_t = s.st_mtime;
ret = 1;
}
}
filedate = localtime(&tm_t);
tmzip->tm_sec = filedate->tm_sec;
tmzip->tm_min = filedate->tm_min;
tmzip->tm_hour = filedate->tm_hour;
zlib/examples/gun.c view on Meta::CPAN
*/
/* external functions and related types and constants */
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strerror(), strcmp(), strlen(), memcpy() */
#include <errno.h> /* errno */
#include <fcntl.h> /* open() */
#include <unistd.h> /* read(), write(), close(), chown(), unlink() */
#include <sys/types.h>
#include <sys/stat.h> /* stat(), chmod() */
#include <utime.h> /* utime() */
#include "zlib.h" /* inflateBackInit(), inflateBack(), */
/* inflateBackEnd(), crc32() */
/* function declaration */
#define local static
/* buffer constants */
#define SIZE 32768U /* input and output buffer sizes */
#define PIECE 16384 /* limits i/o chunks for 16-bit int case */
zlib/examples/gun.c view on Meta::CPAN
/* Copy file attributes, from -> to, as best we can. This is best effort, so
no errors are reported. The mode bits, including suid, sgid, and the sticky
bit are copied (if allowed), the owner's user id and group id are copied
(again if allowed), and the access and modify times are copied. */
local void copymeta(char *from, char *to)
{
struct stat was;
struct utimbuf when;
/* get all of from's Unix meta data, return if not a regular file */
if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG)
return;
/* set to's mode bits, ignore errors */
(void)chmod(to, was.st_mode & 07777);
/* copy owner's user and group, ignore errors */
(void)chown(to, was.st_uid, was.st_gid);
/* copy access and modify times, ignore errors */
when.actime = was.st_atime;
zlib/examples/gzlog.c view on Meta::CPAN
};
#define BODY sizeof(log_gzbody)
/* Exclusively create foo.lock in order to negotiate exclusive access to the
foo.* files. If the modify time of an existing lock file is greater than
PATIENCE seconds in the past, then consider the lock file to have been
abandoned, delete it, and try the exclusive create again. Save the lock
file modify time for verification of ownership. Return 0 on success, or -1
on failure, usually due to an access restriction or invalid path. Note that
if stat() or unlink() fails, it may be due to another process noticing the
abandoned lock file a smidge sooner and deleting it, so those are not
flagged as an error. */
local int log_lock(struct log *log)
{
int fd;
struct stat st;
strcpy(log->end, ".lock");
while ((fd = open(log->path, O_CREAT | O_EXCL, 0644)) < 0) {
if (errno != EEXIST)
return -1;
if (stat(log->path, &st) == 0 && time(NULL) - st.st_mtime > PATIENCE) {
unlink(log->path);
continue;
}
sleep(2); /* relinquish the CPU for two seconds while waiting */
}
close(fd);
if (stat(log->path, &st) == 0)
log->lock = st.st_mtime;
return 0;
}
/* Update the modify time of the lock file to now, in order to prevent another
task from thinking that the lock is stale. Save the lock file modify time
for verification of ownership. */
local void log_touch(struct log *log)
{
struct stat st;
strcpy(log->end, ".lock");
utimes(log->path, NULL);
if (stat(log->path, &st) == 0)
log->lock = st.st_mtime;
}
/* Check the log file modify time against what is expected. Return true if
this is not our lock. If it is our lock, touch it to keep it. */
local int log_check(struct log *log)
{
struct stat st;
strcpy(log->end, ".lock");
if (stat(log->path, &st) || st.st_mtime != log->lock)
return 1;
log_touch(log);
return 0;
}
/* Unlock a previously acquired lock, but only if it's ours. */
local void log_unlock(struct log *log)
{
if (log_check(log))
return;
zlib/examples/gzlog.c view on Meta::CPAN
unsigned char *data = NULL;
size_t len = 0;
struct stat st;
/* log recovery */
log_log(log, op, "start");
/* load foo.add file if expected and present */
if (op == APPEND_OP || op == COMPRESS_OP) {
strcpy(log->end, ".add");
if (stat(log->path, &st) == 0 && st.st_size) {
len = (size_t)(st.st_size);
if ((off_t)len != st.st_size ||
(data = malloc(st.st_size)) == NULL) {
log_log(log, op, "allocation failure");
return -2;
}
if ((fd = open(log->path, O_RDONLY, 0)) < 0) {
free(data);
log_log(log, op, ".add file read failure");
return -1;
zlib/test/minigzip.c view on Meta::CPAN
gzFile out;
{
int len;
int err;
int ifd = fileno(in);
caddr_t buf; /* mmap'ed buffer for the entire input file */
off_t buf_len; /* length of the input file */
struct stat sb;
/* Determine the size of the file, needed for mmap: */
if (fstat(ifd, &sb) < 0) return Z_ERRNO;
buf_len = sb.st_size;
if (buf_len <= 0) return Z_ERRNO;
/* Now do the actual mmap: */
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
if (buf == (caddr_t)(-1)) return Z_ERRNO;
/* Compress the whole file at once: */
len = gzwrite(out, (char *)buf, (unsigned)buf_len);