Added un_attach function development

This commit is contained in:
Michiel Broek 2004-07-16 11:22:07 +00:00
parent 34e2ac5116
commit 3d2ff259a2
3 changed files with 32 additions and 29 deletions

View File

@ -3,6 +3,10 @@ $Id$
v0.61.2 11-Jul-2004 v0.61.2 11-Jul-2004
general:
Added -fno-strict-aliasing switch to gcc to prevent some
warnings.
libmbse.a: libmbse.a:
Added logging for obsolete .tic files in .flo files. Added logging for obsolete .tic files in .flo files.
When files are attached that should "leave" after sent (not When files are attached that should "leave" after sent (not

View File

@ -33,7 +33,14 @@
int attach(faddr noden, char *ofile, int mode, char flavor) /*
* Attach a file to the real outbound fo a given node.
* If fdn == TRUE, the the file is a forwarded tic file, then
* make sure to see if there was an old file with the same name
* that the old attach is removed including the .tic file so
* that we will send the new file with the right .tic file.
*/
int attach(faddr noden, char *ofile, int mode, char flavor, int fdn)
{ {
FILE *fp; FILE *fp;
char *flofile, *thefile; char *flofile, *thefile;
@ -47,6 +54,14 @@ int attach(faddr noden, char *ofile, int mode, char flavor)
return FALSE; return FALSE;
} }
/*
* Check if we attach a file with the same name
*/
if ((fdn) && (un_attach(noden, ofile) == FALSE)) {
WriteError("attach: can't un_attach %s, %s", ofile, strerror(rc));
return FALSE;
}
flofile = calloc(PATH_MAX, sizeof(char)); flofile = calloc(PATH_MAX, sizeof(char));
thefile = calloc(PATH_MAX, sizeof(char)); thefile = calloc(PATH_MAX, sizeof(char));
sprintf(flofile, "%s", floname(&noden, flavor)); sprintf(flofile, "%s", floname(&noden, flavor));
@ -109,33 +124,6 @@ int attach(faddr noden, char *ofile, int mode, char flavor)
break; break;
} }
fseek(fp, 0, SEEK_SET);
while (fgets(flofile, PATH_MAX -1, fp) != NULL) {
Striplf(flofile);
if (strncmp(flofile, thefile, strlen(thefile)) == 0) {
Syslog('+', "attach: file %s already attached", ofile);
/*
* If one of the next entries in the .flo file is a .tic file
* pointing to this file, we should remove that .tic file and
* mark the entry in the .flo as sent. For the file with this
* name, a new .tic file will be added.
*/
while (fgets(flofile, PATH_MAX -1, fp) != NULL) {
Striplf(flofile);
if (strstr(flofile, (char *)".tic")) {
/*
* Check this .tic file
*/
Syslog('f', "Should check %s to be deleted", flofile);
}
}
fclose(fp);
free(flofile);
free(thefile);
return TRUE;
}
}
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
fprintf(fp, "%s\r\n", thefile); fprintf(fp, "%s\r\n", thefile);
fclose(fp); fclose(fp);
@ -146,3 +134,13 @@ int attach(faddr noden, char *ofile, int mode, char flavor)
/*
* Remove a file from the flofile, also search for a .tic file.
*/
int un_attach(faddr node, char *filename)
{
Syslog('p', "un_attach: %s %s", fido2faddr(node), filename);
return TRUE;
}

View File

@ -2114,7 +2114,8 @@ int le_int(int);
/* /*
* From attach.c * From attach.c
*/ */
int attach(faddr, char *, int, char); int attach(faddr, char *, int, char, int);
int un_attach(faddr, char *);