/* -*-c-*-
*
- * $Id: file.c,v 1.1 1999/07/26 23:33:32 mdw Exp $
- *
* File source and target
*
* (c) 1999 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of the `fw' port forwarder.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* `fw' is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with `fw'; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: file.c,v $
- * Revision 1.1 1999/07/26 23:33:32 mdw
- * New sources and targets.
- *
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "config.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <mLib/alloc.h>
-#include <mLib/dstr.h>
-#include <mLib/fdflags.h>
-#include <mLib/sub.h>
-
-#include "conf.h"
-#include "endpt.h"
-#include "fattr.h"
-#include "file.h"
#include "fw.h"
-#include "reffd.h"
-#include "scan.h"
-#include "source.h"
-#include "target.h"
/*----- Data structures ---------------------------------------------------*/
typedef struct fsource {
source s;
fdata f;
-} fsource;
+} fsource;
/* --- File target block --- */
/* --- Endpoint operations table --- */
-static endpt_ops fept_ops = { 0, fept_wclose, fept_close };
+static endpt_ops fept_ops = { 0, 0, fept_wclose, fept_close };
/*----- General operations on sources and targets -------------------------*/
reffd_handler(rnull, file_null, 0);
}
return (rnull);
-}
+}
/* --- @file_fspec@ --- *
*
else if (fd) {
f->type = FTYPE_FD;
f->u.fd = fd;
- token(sc);
+ token(sc);
} else if (type == FTYPE_FD) {
if (sc->t == CTOK_WORD)
error(sc, "bad file descriptor `%s'", sc->d.buf);
case FTYPE_NULL:
dstr_puts(d, "null");
break;
- }
+ }
}
static void file_desc(fdata *f, dstr *d)
if (fd != -1) {
if (fattr_apply(f->out.u.name, &f->fa)) {
- fw_log(-1, "[%s] couldn't apply file attributes: %s",
+ fw_log(-1, "[%s] couldn't apply file attributes to `%s': %s",
desc, f->out.u.name, strerror(errno));
}
} else if ((fd = open(f->out.u.name, m & ~O_CREAT)) < 0) {
static void file_destroy(fdata *f)
{
if (f->in.type == FTYPE_NAME)
- free(f->in.u.name);
+ xfree(f->in.u.name);
if (f->out.type == FTYPE_NAME)
- free(f->out.u.name);
+ xfree(f->out.u.name);
}
/*----- File source description -------------------------------------------*/
static void fsource_destroy(source *s)
{
fsource *fs = (fsource *)s;
-
- /* free(fs->s.desc); */
+ xfree(fs->s.desc);
file_destroy(&fs->f);
DESTROY(fs);
}
{
ftarget *ft = (ftarget *)t;
file_destroy(&ft->f);
- /* free(ft->t.desc); */
+ xfree(ft->t.desc);
DESTROY(ft);
}
target_ops ftarget_ops = {
"file",
- ftarget_option, ftarget_read, ftarget_create, ftarget_destroy
+ ftarget_option, ftarget_read, 0, ftarget_create, ftarget_destroy
};
/*----- That's all, folks -------------------------------------------------*/