2 * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file file_writer.c simple output plugin for testing purposes */
26 struct private_file_writer_data
{
29 static int file_writer_open(struct writer_node
*w
)
31 struct private_file_writer_data
*pfwd
= para_calloc(
32 sizeof(struct private_file_writer_data
));
33 char *tmp
= para_tmpname(), *home
= para_homedir(),
34 *filename
= make_message("%s/.paraslash/%s", home
, tmp
);
38 w
->private_data
= pfwd
;
39 pfwd
->fd
= open(filename
, O_WRONLY
| O_CREAT
, S_IRUSR
| S_IWUSR
);
47 static int file_writer_write(char *data
, size_t nbytes
, struct writer_node
*wn
)
49 struct private_file_writer_data
*pfwd
= wn
->private_data
;
50 int ret
= write(pfwd
->fd
, data
, nbytes
);
56 static void file_writer_close(struct writer_node
*wn
)
58 struct private_file_writer_data
*pfwd
= wn
->private_data
;
63 void file_writer_init(struct writer
*w
)
65 w
->open
= file_writer_open
;
66 w
->write
= file_writer_write
;
67 w
->close
= file_writer_close
;
68 w
->shutdown
= NULL
; /* nothing to do */