Code cleanup initial tic processing
This commit is contained in:
parent
7fd012a6de
commit
c8f93b2ac5
42
mbfido/tic.c
42
mbfido/tic.c
@ -98,30 +98,29 @@ int Tic()
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((de = readdir(dp)))
|
||||
if ((strlen(de->d_name) == 12) &&
|
||||
(strncasecmp(de->d_name+11, "c", 1) == 0)) {
|
||||
if ((strncasecmp(de->d_name+8, ".a", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".c", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".z", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".l", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".r", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".0", 2) == 0)) {
|
||||
while ((de = readdir(dp))) {
|
||||
if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+11, "c", 1) == 0)) {
|
||||
if ((strncasecmp(de->d_name+8, ".a", 2) == 0) || (strncasecmp(de->d_name+8, ".c", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".z", 2) == 0) || (strncasecmp(de->d_name+8, ".l", 2) == 0) ||
|
||||
(strncasecmp(de->d_name+8, ".r", 2) == 0) || (strncasecmp(de->d_name+8, ".0", 2) == 0)) {
|
||||
if (checkspace(inbound, de->d_name, UNPACK_FACTOR)) {
|
||||
if ((unpack(de->d_name)) != 0) {
|
||||
WriteError("Error unpacking %s", de->d_name);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
Syslog('+', "Insufficient space to unpack file %s", de->d_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rewinddir(dp);
|
||||
while ((de = readdir(dp)))
|
||||
while ((de = readdir(dp))) {
|
||||
if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+8, ".tic", 4) == 0)) {
|
||||
stat(de->d_name, &sbuf);
|
||||
fill_fdlist(&fdl, de->d_name, sbuf.st_mtime);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
sort_fdlist(&fdl);
|
||||
@ -167,9 +166,8 @@ int LoadTic(char *inb, char *tfn)
|
||||
{
|
||||
FILE *tfp;
|
||||
char *Temp, *Temp2, *Buf, *Log = NULL;
|
||||
int i, j, rc, bufsize;
|
||||
int i, j, rc, bufsize, DescCnt = FALSE;
|
||||
fa_list *sbl = NULL;
|
||||
int DescCnt = FALSE;
|
||||
|
||||
if (CFG.slow_util && do_quiet)
|
||||
usleep(1);
|
||||
@ -204,15 +202,16 @@ int LoadTic(char *inb, char *tfn)
|
||||
Syslog('!', "Detected a TIC file line of %d characters long", bufsize);
|
||||
|
||||
/*
|
||||
* Remove all garbage from the .TIC file.
|
||||
* Remove all garbage from this tic line.
|
||||
*/
|
||||
Temp[0] = '\0';
|
||||
j = 0;
|
||||
for (i = 0; i < strlen(Buf); i++)
|
||||
for (i = 0; i < strlen(Buf); i++) {
|
||||
if (isprint(Buf[i] & 0x7f)) {
|
||||
Temp[j] = Buf[i] & 0x7f;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
Temp[j] = '\0';
|
||||
|
||||
if (strncasecmp(Temp, "hatch", 5) == 0) {
|
||||
@ -266,6 +265,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
} else {
|
||||
Syslog('!', "More than one \"Desc\" line");
|
||||
}
|
||||
|
||||
} else if (strncasecmp(Temp, "path ", 5) == 0) {
|
||||
strncpy(TIC.TicIn.Path[TIC.TicIn.TotPath], Temp+5, 80);
|
||||
TIC.TicIn.TotPath++;
|
||||
@ -278,6 +278,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
TIC.TicIn.PathError = TRUE;
|
||||
Syslog('+', "Aka %d: %s in path", i + 1, aka2str(CFG.aka[i]));
|
||||
}
|
||||
|
||||
} else if (strncasecmp(Temp, "seenby ", 7) == 0) {
|
||||
fill_list(&sbl, Temp+7, NULL);
|
||||
|
||||
@ -287,6 +288,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
} else if (strncasecmp(Temp, "to ", 3) == 0) {
|
||||
/*
|
||||
* Drop this one
|
||||
* FIXME: should check if this is for us.
|
||||
*/
|
||||
} else if (strncasecmp(Temp, "size ", 5) == 0) {
|
||||
TIC.TicIn.Size = atoi(Temp+5);
|
||||
@ -305,6 +307,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
strncpy(TIC.TicIn.LDesc[TIC.TicIn.TotLDesc], Temp+6, 80);
|
||||
TIC.TicIn.TotLDesc++;
|
||||
}
|
||||
|
||||
} else if (strncasecmp(Temp, "destination ", 12) == 0) {
|
||||
/*
|
||||
* Drop this one
|
||||
@ -416,7 +419,8 @@ int LoadTic(char *inb, char *tfn)
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Find out what the real name of the file is
|
||||
* Find out what the real name of the file is,
|
||||
* most likely this is a 8.3 filename.
|
||||
*/
|
||||
sprintf(Temp2, "%s", TIC.TicIn.File);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
@ -435,6 +439,11 @@ int LoadTic(char *inb, char *tfn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the above didn't find the file and we got a LFN
|
||||
* the search again.
|
||||
*/
|
||||
if (strlen(TIC.TicIn.FullName) && (strlen(TIC.RealName) == 0)) {
|
||||
sprintf(Temp2, "%s", TIC.TicIn.FullName);
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, Temp2);
|
||||
@ -464,6 +473,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
WriteError("Can't find file in inbound");
|
||||
} else {
|
||||
Syslog('f', "Real filename in inbound is \"%s\"", TIC.RealName);
|
||||
Syslog('f', "8.3 name \"%s\", LFN \"%s\"", TIC.TicIn.File, TIC.TicIn.FullName);
|
||||
strncpy(TIC.NewName, TIC.RealName, 80);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user