/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <libpspp/alloc.h>
#include <libpspp/version.h>
static char *command_name;
/* Message handler as set by msg_init(). */
-static void (*msg_handler) (const struct msg *);
+static void (*msg_handler) (const struct msg *);
+static void (*msg_location) (struct msg_locator *);
+
/* Public functions. */
m.category = msg_class_to_category (class);
m.severity = msg_class_to_severity (class);
- msg_location (&m.where);
va_start (args, format);
m.text = xvasprintf (format, args);
va_end (args);
}
void
-msg_init (void (*handler) (const struct msg *))
+msg_init ( void (*handler) (const struct msg *),
+ void (*location) (struct msg_locator *) )
{
msg_handler = handler;
+ msg_location = location;
}
void
{
}
+
+/* Duplicate a message */
+struct msg *
+msg_dup(const struct msg *m)
+{
+ struct msg *new_msg = xmalloc (sizeof *m);
+
+ *new_msg = *m;
+ new_msg->text = strdup(m->text);
+
+ return new_msg;
+}
+
+void
+msg_destroy(struct msg *m)
+{
+ free(m->text);
+ free(m);
+}
+
+
/* Emits M as an error message.
Frees allocated data in M. */
void
msg_emit (struct msg *m)
{
+ msg_location (&m->where);
msg_handler (m);
free (m->text);
}
"build_system: %s\n"
"default_config_path: %s\n"
"include_path: %s\n"
- "groff_font_path: %s\n"
"locale_dir: %s\n"
"compiler version: %s\n"
,
build_system,
default_config_path,
include_path,
- groff_font_path,
locale_dir,
#ifdef __VERSION__
__VERSION__