/* ------------------------------------------------------------------------- */ static int out_readflo(s_filelist **fslist, const char *floname, int flavor, bool aso, int flodsc) { s_FLO *FLO; s_filelist **tmpl; struct stat st; int type; DEB((D_OUTBOUND, "out_readflo: opening flo file \"%s\"", floname)); if( (FLO = flo_open(floname, "r")) == NULL ) { logerr("can't open flo \"%s\"", floname); return -1; } for( tmpl = fslist; *tmpl; tmpl = &(*tmpl)->next ); while( flo_next(FLO) == 0 ) { if( stat(FLO->att_path, &st) == 0 ) { type = out_filetype(FLO->att_path); type |= TYPE_FROMFLO; type |= aso ? TYPE_ASONAME : 0; (*tmpl) = (s_filelist*)xmalloc(sizeof(s_filelist)); memset(*tmpl, '\0', sizeof(s_filelist)); (*tmpl)->fname = (char *)xstrcpy(FLO->att_path); (*tmpl)->size = st.st_size; (*tmpl)->type = type; (*tmpl)->flavor = flavor; (*tmpl)->action = FLO->att_action; (*tmpl)->status = STATUS_WILLSEND; (*tmpl)->flodsc = flodsc; tmpl = &(*tmpl)->next; } else logerr("can't stat file \"%s\" from flo \"%s\"", FLO->att_path, floname); } flo_close(FLO); return 0; }
/* * Attach file to FLO control file */ int bink_attach(Node *node, int mode, char *name, char *flav, int bsy) { FILE *fp; char *n; char *line; int lmode, found; static char buf[MAXPATH]; if(mode) debug(4, "attach mode=%c (^=delete, #=trunc)", mode); debug(4, "attach name=%s", name); if(cf_dos()) /* MSDOS translation enabled? */ { n = cf_dos_xlate(name); if(!n) { fglog("can't convert file name to MSDOS: %s", name); return ERROR; } debug(4, "attach MSDOS name=%s", n); } else n = name; if(flo_openx(node, bsy, flav, TRUE) == ERROR) return ERROR; fp = flo_file(); /* seek to start of flo file */ if(fseek(fp, 0L, SEEK_SET) == ERROR) { fglog("$fseek EOF FLO file node %s failed", znfp1(node)); flo_close(node, TRUE, FALSE); return ERROR; } /* read FLO entries, check if file attachment exists */ found = FALSE; while( (line = flo_gets(buf, sizeof(buf))) ) { if(*line == '~') continue; lmode = ' '; if(*line == '^' || *line == '#') lmode = *line++; debug(5, "FLO entry: %c %s", lmode, line); if(streq(line, n)) { found = TRUE; debug(5, " found entry"); } } /* We're there ... */ if(found) debug(4, "FLO file already contains an entry, not attaching file"); else { debug(4, "FLO file open and locking succeeded, attaching file"); if(mode) fprintf(fp, "%c%s%s", mode, n, cf_dos() ? "\r\n" : "\n" ); else fprintf(fp, "%s%s" , n, cf_dos() ? "\r\n" : "\n" ); } flo_close(node, bsy, FALSE); return OK; }