2015-01-30 20:37:14 +01:00
|
|
|
/*
|
2010-08-08 10:06:34 +02:00
|
|
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
| | Enno Rehling <enno@eressea.de>
|
|
|
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
|
|
|
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
|
|
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|
|
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
This program may not be used, modified or distributed
|
2010-08-08 10:06:34 +02:00
|
|
|
without prior permission by the authors of Eressea.
|
2015-01-30 20:37:14 +01:00
|
|
|
*/
|
2014-06-09 18:54:48 +02:00
|
|
|
#ifndef H_MESSAGE_H
|
|
|
|
#define H_MESSAGE_H
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#include "variant.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct arg_type {
|
|
|
|
struct arg_type *next;
|
|
|
|
variant_type vtype;
|
|
|
|
const char *name;
|
|
|
|
void(*release) (variant);
|
|
|
|
variant(*copy) (variant);
|
|
|
|
} arg_type;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct message_type {
|
|
|
|
unsigned int key;
|
2015-08-17 19:35:07 +02:00
|
|
|
char *name;
|
2015-01-30 20:37:14 +01:00
|
|
|
int nparameters;
|
2015-08-17 19:35:07 +02:00
|
|
|
char **pnames;
|
|
|
|
struct arg_type ** types;
|
2015-01-30 20:37:14 +01:00
|
|
|
} message_type;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct message {
|
|
|
|
const struct message_type *type;
|
|
|
|
variant *parameters;
|
|
|
|
int refcount;
|
|
|
|
} message;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-08-17 19:35:07 +02:00
|
|
|
void mt_clear(void);
|
|
|
|
struct message_type *mt_new(const char *name, const char **args);
|
|
|
|
struct message_type *mt_new_va(const char *name, ...);
|
2015-01-30 20:37:14 +01:00
|
|
|
/* mt_new("simple_sentence", "subject:string", "predicate:string",
|
|
|
|
* "object:string", "lang:locale", NULL); */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
extern struct message *msg_create(const struct message_type *type,
|
|
|
|
variant args[]);
|
|
|
|
/* msg_create(&mt_simplesentence, "enno", "eats", "chocolate", &locale_de);
|
|
|
|
* parameters must be in the same order as they were for mt_new! */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
extern void msg_release(struct message *msg);
|
|
|
|
extern struct message *msg_addref(struct message *msg);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
extern const char *mt_name(const struct message_type *mtype);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
/** message_type registry (optional): **/
|
|
|
|
extern const struct message_type *mt_register(struct message_type *);
|
|
|
|
extern const struct message_type *mt_find(const char *);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
extern void register_argtype(const char *name, void(*free_arg) (variant),
|
|
|
|
variant(*copy_arg) (variant), variant_type);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-08-17 19:35:07 +02:00
|
|
|
void(*msg_log_create) (const struct message * msg);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-06-09 18:54:48 +02:00
|
|
|
|