projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ascii: Always include <sys/ioctl.h> if we're calling ioctl.
[pspp]
/
src
/
output
/
msglog.c
diff --git
a/src/output/msglog.c
b/src/output/msglog.c
index d5c68069a6f9cbe1aec0d80bc5cb3c1b6694fc46..7fe6555f19dc4acc8f0d16ff3812392f5d9fbbd9 100644
(file)
--- a/
src/output/msglog.c
+++ b/
src/output/msglog.c
@@
-24,12
+24,13
@@
#include <unistd.h>
#include "data/file-name.h"
#include <unistd.h>
#include "data/file-name.h"
+#include "data/file-handle-def.h"
#include "data/settings.h"
#include "libpspp/cast.h"
#include "data/settings.h"
#include "libpspp/cast.h"
+#include "libpspp/message.h"
#include "output/driver-provider.h"
#include "output/driver-provider.h"
-#include "output/
message
-item.h"
+#include "output/
output
-item.h"
-#include "gl/error.h"
#include "gl/fwriteerror.h"
#include "gl/xalloc.h"
#include "gl/fwriteerror.h"
#include "gl/xalloc.h"
@@
-40,8
+41,7
@@
struct msglog_driver
{
struct output_driver driver;
FILE *file;
{
struct output_driver driver;
FILE *file;
- char *file_name;
- char *command_name;
+ struct file_handle *handle;
};
static const struct output_driver_class msglog_class;
};
static const struct output_driver_class msglog_class;
@@
-60,10
+60,12
@@
msglog_create (const char *file_name)
struct msglog_driver *ml;
FILE *file;
struct msglog_driver *ml;
FILE *file;
- file = fn_open (file_name, "w");
+ struct file_handle *handle = fh_create_file (NULL, file_name, NULL, fh_default_properties ());
+
+ file = fn_open (handle, "w");
if (file == NULL)
{
if (file == NULL)
{
-
error (0, errno, _("%s: open failed
"), file_name);
+
msg_error (errno, _("error opening output file `%s'
"), file_name);
return NULL;
}
return NULL;
}
@@
-72,10
+74,9
@@
msglog_create (const char *file_name)
: SETTINGS_DEVICE_UNFILTERED);
ml = xzalloc (sizeof *ml);
: SETTINGS_DEVICE_UNFILTERED);
ml = xzalloc (sizeof *ml);
+ ml->handle = handle;
output_driver_init (&ml->driver, &msglog_class, file_name, type);
ml->file = file;
output_driver_init (&ml->driver, &msglog_class, file_name, type);
ml->file = file;
- ml->file_name = xstrdup (file_name);
- ml->command_name = NULL;
output_driver_register (&ml->driver);
output_driver_register (&ml->driver);
@@
-87,9
+88,8
@@
msglog_destroy (struct output_driver *driver)
{
struct msglog_driver *ml = msglog_driver_cast (driver);
{
struct msglog_driver *ml = msglog_driver_cast (driver);
- fn_close (ml->file_name, ml->file);
- free (ml->file_name);
- free (ml->command_name);
+ fn_close (ml->handle, ml->file);
+ fh_unref (ml->handle);
free (ml);
}
free (ml);
}
@@
-98,13
+98,9
@@
msglog_submit (struct output_driver *driver, const struct output_item *item)
{
struct msglog_driver *ml = msglog_driver_cast (driver);
{
struct msglog_driver *ml = msglog_driver_cast (driver);
- output_driver_track_current_command (item, &ml->command_name);
-
- if (is_message_item (item))
+ if (item->type == OUTPUT_ITEM_MESSAGE)
{
{
- const struct message_item *message_item = to_message_item (item);
- const struct msg *msg = message_item_get_msg (message_item);
- char *s = msg_to_string (msg, ml->command_name);
+ char *s = msg_to_string (item->message);
fprintf (ml->file, "%s\n", s);
free (s);
}
fprintf (ml->file, "%s\n", s);
free (s);
}
@@
-112,8
+108,7
@@
msglog_submit (struct output_driver *driver, const struct output_item *item)
static const struct output_driver_class msglog_class =
{
static const struct output_driver_class msglog_class =
{
- "msglog",
- msglog_destroy,
- msglog_submit,
- NULL
+ .name = "msglog",
+ .destroy = msglog_destroy,
+ .submit = msglog_submit,
};
};