Tab chars (0x9) was replaced with spaces

This commit is contained in:
Ianos Gnatiuc
2005-10-23 04:39:25 +00:00
parent 1f4f8695e5
commit 9813ce1e91
34 changed files with 5256 additions and 5256 deletions

View File

@@ -150,15 +150,15 @@ long fsize(const char *filename)
if (ff)
{
#ifndef UNIX
ret = ff->ff_fsize;
if (ret != -1L) {
ret = ff->ff_fsize;
if (ret != -1L) {
#endif
fp = fopen(filename, "rb");
fseek(fp, 0, SEEK_END);
ret = ftell(fp);
fclose(fp);
fp = fopen(filename, "rb");
fseek(fp, 0, SEEK_END);
ret = ftell(fp);
fclose(fp);
#ifndef UNIX
};
};
#endif
FFindClose(ff);
}

View File

@@ -139,11 +139,11 @@ FFIND *FFindOpen(const char *filespec, uint16_t attribute)
strcpy(ff->lastbit, filespec);
}
else if (p == filespec)
{
strcpy(ff->firstbit, "/");
strcpy(ff->lastbit, filespec+1);
}
else
{
strcpy(ff->firstbit, "/");
strcpy(ff->lastbit, filespec+1);
}
else
{
memcpy(ff->firstbit, filespec, p - filespec);
ff->firstbit[p - filespec] = '\0';
@@ -168,9 +168,9 @@ FFIND *FFindOpen(const char *filespec, uint16_t attribute)
{
strncpy(ff->ff_name, de->d_name, sizeof ff->ff_name);
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
fin = 1;
}
}
@@ -341,10 +341,10 @@ int FFindNext(FFIND * ff)
{
strncpy(ff->ff_name, de->d_name, sizeof ff->ff_name);
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
fin = 1;
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
fin = 1;
rc = 0;
}
}

View File

@@ -46,138 +46,138 @@
#include "hsksupp.h"
#include "ffind.h"
#define MAX_OUTRUN (3ul*365*24*60*60) /* 3 year */
#define MAX_OUTRUN (3ul*365*24*60*60) /* 3 year */
#define GenMsgIdErr(a) { if (errstr!=NULL) { *errstr = a; } }
dword oldGenMsgId(void)
{
dword seq = (dword)time(NULL);
sleep(1);
return seq;
dword seq = (dword)time(NULL);
sleep(1);
return seq;
}
dword GenMsgIdEx(char *seqdir, unsigned long max_outrun, dword (*altGenMsgId)(void), char **errstr)
{
dword seq, n, curtime;
FFIND *ff;
char *seqpath, max_fname[13], *new_fname, *pname, *p;
int h, try;
dword seq, n, curtime;
FFIND *ff;
char *seqpath, max_fname[13], *new_fname, *pname, *p;
int h, try;
if (altGenMsgId == NULL)
altGenMsgId = oldGenMsgId;
GenMsgIdErr(NULL);
if (altGenMsgId == NULL)
altGenMsgId = oldGenMsgId;
GenMsgIdErr(NULL);
if (seqdir == NULL || *seqdir == '\0') {
seqdir = getenv("SEQDIR");
if (seqdir == NULL || *seqdir == '\0') {
/* warning: no SEQDIR defined, fall to ugly old algorythm */
GenMsgIdErr("no SEQDIR defined");
return (*altGenMsgId)();
}
}
seqpath = malloc(strlen(seqdir)+13);
strcpy(seqpath, seqdir);
pname = seqpath + strlen(seqpath);
if (*seqpath && strchr("/\\", seqpath[strlen(seqpath)-1]) == NULL)
*pname++ = PATH_DELIM;
new_fname = NULL;
if (max_outrun == 0) {
p = getenv("SEQOUT");
if ( p && isdigit((int)(*p)) ) {
max_outrun = (unsigned long)atol(p);
switch (tolower(p[strlen(p) - 1])) {
case 'y': max_outrun *= 365;
case 'd': max_outrun *= 24;
case 'h': max_outrun *= 60*60;
break;
case 'w': max_outrun *= (7l*24*60*60);
break;
case 'm': max_outrun *= (31l*24*60*60);
break;
}
}
else max_outrun = MAX_OUTRUN;
}
for (try=0;;try++) {
curtime = (dword)time(NULL);
seq = 0;
max_fname[0] = '\0';
strcpy(pname, "*.*");
ff = FFindOpen(seqpath, 0);
if (ff == NULL) { /* file not found */
*pname = '\0';
if (try == 0) {
if (direxist(seqpath))
goto emptydir; /* directory exist & empty */
else if (_createDirectoryTree(seqpath) == 0)
goto emptydir; /* directory created */
} /* if directory not created at 1st time then use old alghorithm */
free(seqpath);
if (new_fname) free(new_fname);
GenMsgIdErr("can't open/create SEQDIR directory");
return (*altGenMsgId)();
}
do {
for (p=ff->ff_name; isxdigit((int)(*p)); p++);
if (stricmp(p, ".seq") != 0) continue;
if (strlen(ff->ff_name) > 12) continue;
n = strtol(ff->ff_name, NULL, 16);
if (n > curtime && n - curtime > max_outrun) {
/* counter too large, remove */
strcpy(pname, ff->ff_name);
unlink(seqpath);
continue;
}
if (n >= seq) {
if (max_fname[0]) {
strcpy(pname, max_fname);
unlink(seqpath);
}
strcpy(max_fname, ff->ff_name);
seq = n;
} else {
strcpy(pname, ff->ff_name);
unlink(seqpath);
}
} while (FFindNext(ff) == 0);
if (ff) FFindClose(ff);
if (seqdir == NULL || *seqdir == '\0') {
seqdir = getenv("SEQDIR");
if (seqdir == NULL || *seqdir == '\0') {
/* warning: no SEQDIR defined, fall to ugly old algorythm */
GenMsgIdErr("no SEQDIR defined");
return (*altGenMsgId)();
}
}
seqpath = malloc(strlen(seqdir)+13);
strcpy(seqpath, seqdir);
pname = seqpath + strlen(seqpath);
if (*seqpath && strchr("/\\", seqpath[strlen(seqpath)-1]) == NULL)
*pname++ = PATH_DELIM;
new_fname = NULL;
if (max_outrun == 0) {
p = getenv("SEQOUT");
if ( p && isdigit((int)(*p)) ) {
max_outrun = (unsigned long)atol(p);
switch (tolower(p[strlen(p) - 1])) {
case 'y': max_outrun *= 365;
case 'd': max_outrun *= 24;
case 'h': max_outrun *= 60*60;
break;
case 'w': max_outrun *= (7l*24*60*60);
break;
case 'm': max_outrun *= (31l*24*60*60);
break;
}
}
else max_outrun = MAX_OUTRUN;
}
for (try=0;;try++) {
curtime = (dword)time(NULL);
seq = 0;
max_fname[0] = '\0';
strcpy(pname, "*.*");
ff = FFindOpen(seqpath, 0);
if (ff == NULL) { /* file not found */
*pname = '\0';
if (try == 0) {
if (direxist(seqpath))
goto emptydir; /* directory exist & empty */
else if (_createDirectoryTree(seqpath) == 0)
goto emptydir; /* directory created */
} /* if directory not created at 1st time then use old alghorithm */
free(seqpath);
if (new_fname) free(new_fname);
GenMsgIdErr("can't open/create SEQDIR directory");
return (*altGenMsgId)();
}
do {
for (p=ff->ff_name; isxdigit((int)(*p)); p++);
if (stricmp(p, ".seq") != 0) continue;
if (strlen(ff->ff_name) > 12) continue;
n = strtol(ff->ff_name, NULL, 16);
if (n > curtime && n - curtime > max_outrun) {
/* counter too large, remove */
strcpy(pname, ff->ff_name);
unlink(seqpath);
continue;
}
if (n >= seq) {
if (max_fname[0]) {
strcpy(pname, max_fname);
unlink(seqpath);
}
strcpy(max_fname, ff->ff_name);
seq = n;
} else {
strcpy(pname, ff->ff_name);
unlink(seqpath);
}
} while (FFindNext(ff) == 0);
if (ff) FFindClose(ff);
emptydir:
if (seq < curtime) seq = curtime;
if (new_fname == NULL)
new_fname = malloc(strlen(seqpath) + 13);
*pname = '\0';
sprintf(new_fname, "%s%08lx.seq", seqpath, (unsigned long)(seq + 1));
if (max_fname[0] == '\0') {
/* No files found, create new */
h = open(new_fname, O_CREAT|O_BINARY|O_EXCL, 0666);
if (h != -1) {
/* ok, scan again */
close(h);
continue;
}
/* error creating file */
if (errno == EEXIST) continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("error creating file in SEQDIR directory");
return (*altGenMsgId)();
}
/* rename max_fname to new_fname */
strcpy(pname, max_fname);
if (rename(seqpath, new_fname) == 0) {
free(seqpath);
free(new_fname);
return seq;
}
if (errno == ENOENT || errno == EEXIST ||
((errno == EPERM || errno == EACCES) && try < 16))
continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("can't rename .seq file");
return (*altGenMsgId)();
}
if (seq < curtime) seq = curtime;
if (new_fname == NULL)
new_fname = malloc(strlen(seqpath) + 13);
*pname = '\0';
sprintf(new_fname, "%s%08lx.seq", seqpath, (unsigned long)(seq + 1));
if (max_fname[0] == '\0') {
/* No files found, create new */
h = open(new_fname, O_CREAT|O_BINARY|O_EXCL, 0666);
if (h != -1) {
/* ok, scan again */
close(h);
continue;
}
/* error creating file */
if (errno == EEXIST) continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("error creating file in SEQDIR directory");
return (*altGenMsgId)();
}
/* rename max_fname to new_fname */
strcpy(pname, max_fname);
if (rename(seqpath, new_fname) == 0) {
free(seqpath);
free(new_fname);
return seq;
}
if (errno == ENOENT || errno == EEXIST ||
((errno == EPERM || errno == EACCES) && try < 16))
continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("can't rename .seq file");
return (*altGenMsgId)();
}
}
dword GenMsgId(char *seqdir, unsigned long max_outrun)