simplify function specifications in CTABLES
[pspp] / src / output / msglog.c
index 0d0329571045daa79b48190e3a22b1600250f9c7..20cfe3a3b2a74384b9073a64bf8ea3daf9881189 100644 (file)
@@ -29,7 +29,7 @@
 #include "libpspp/cast.h"
 #include "libpspp/message.h"
 #include "output/driver-provider.h"
-#include "output/message-item.h"
+#include "output/output-item.h"
 
 #include "gl/fwriteerror.h"
 #include "gl/xalloc.h"
@@ -42,7 +42,6 @@ struct msglog_driver
     struct output_driver driver;
     FILE *file;
     struct file_handle *handle;
-    char *command_name;
   };
 
 static const struct output_driver_class msglog_class;
@@ -58,7 +57,6 @@ struct output_driver *
 msglog_create (const char *file_name)
 {
   enum settings_output_devices type;
-  struct msglog_driver *ml;
   FILE *file;
 
   struct file_handle *handle = fh_create_file  (NULL, file_name, NULL, fh_default_properties ());
@@ -74,11 +72,10 @@ msglog_create (const char *file_name)
           ? SETTINGS_DEVICE_TERMINAL
           : SETTINGS_DEVICE_UNFILTERED);
 
-  ml = xzalloc (sizeof *ml);
+  struct msglog_driver *ml = XZALLOC (struct msglog_driver);
   ml->handle = handle;
   output_driver_init (&ml->driver, &msglog_class, file_name, type);
   ml->file = file;
-  ml->command_name = NULL;
 
   output_driver_register (&ml->driver);
 
@@ -91,7 +88,6 @@ msglog_destroy (struct output_driver *driver)
   struct msglog_driver *ml = msglog_driver_cast (driver);
 
   fn_close (ml->handle, ml->file);
-  free (ml->command_name);
   fh_unref (ml->handle);
   free (ml);
 }
@@ -101,13 +97,9 @@ msglog_submit (struct output_driver *driver, const struct output_item *item)
 {
   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);
     }
@@ -115,8 +107,7 @@ msglog_submit (struct output_driver *driver, const struct output_item *item)
 
 static const struct output_driver_class msglog_class =
   {
-    "msglog",
-    msglog_destroy,
-    msglog_submit,
-    NULL
+    .name = "msglog",
+    .destroy = msglog_destroy,
+    .submit = msglog_submit,
   };