--- l2.h 2001/05/11 17:07:52 1.2
+++ l2.h 2001/05/19 20:08:30 1.3
@@ -30,18 +30,33 @@
#ifndef __L2_H__
#define __L2_H__
+/* include standard environment we are based on */
+#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+/* counterbalance poor standard environments */
+#ifndef NULL
+#define NULL (void *)0
+#endif
+#ifndef FALSE
+#define FALSE (0)
+#endif
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
/* forward declarations for opaque data structures */
union l2_context_un;
+struct l2_param_st;
struct l2_stream_st;
struct l2_channel_st;
struct l2_handler_st;
/* corresponding data types for data structures */
typedef union l2_context_un l2_context_t;
+typedef struct l2_param_st l2_param_t;
typedef struct l2_handler_st l2_handler_t;
typedef struct l2_stream_st l2_stream_t;
typedef struct l2_channel_st l2_channel_t;
@@ -64,16 +79,43 @@
L2_ERROR
} l2_error_t;
-/* context union for callbacks */
+/* context union for storing data */
union l2_context_un {
+ char c;
+ short s;
int i;
long l;
float f;
double d;
- void *vp;
char *cp;
+ void *vp;
+};
+
+/* list of types for storing data */
+typedef enum {
+ L2_TYPE_CHAR,
+ L2_TYPE_SHORT,
+ L2_TYPE_INT,
+ L2_TYPE_LONG,
+ L2_TYPE_FLOAT,
+ L2_TYPE_DOUBLE,
+ L2_TYPE_CHARPTR,
+ L2_TYPE_VOIDPTR
+} l2_type_t;
+
+/* parameter specification */
+struct l2_param_st {
+ char *name;
+ l2_type_t type;
+ void *store;
};
+/* parameter constructors */
+#define L2_PARAM_SET(pa,n,t,s) \
+ pa.name = #n, pa.type = L2_TYPE_##t, pa.store = s
+#define L2_PARAM_END(pa) \
+ pa.name = NULL
+
/* channel handler specification structure */
struct l2_handler_st {
int (*create) (l2_context_t *ctx);
@@ -108,6 +150,9 @@
extern l2_handler_t l2_handler_prefix;
extern l2_handler_t l2_handler_buffer;
+/* parameter operations */
+int l2_param_parse (l2_param_t p[], const char *fmt, va_list ap);
+
/* channel operations */
l2_channel_t *l2_channel_create (l2_handler_t *h);
l2_channel_t *l2_channel_stack (l2_channel_t *ch1, l2_channel_t *ch2);
|