--- var.h 2004/04/04 08:07:34 1.31
+++ var.h 2004/10/29 19:42:20 1.32
@@ -31,10 +31,22 @@
#ifndef __VAR_H__
#define __VAR_H__
+/* required system headers */
#include <stdlib.h>
#include <stdarg.h>
-/* Error codes */
+/* minimum C++ support */
+#ifdef __cplusplus
+#define DECLARATION_BEGIN extern "C" {
+#define DECLARATION_END }
+#else
+#define DECLARATION_BEGIN
+#define DECLARATION_END
+#endif
+
+DECLARATION_BEGIN
+
+/* error codes */
typedef enum {
VAR_ERR_CALLBACK = -64,
VAR_ERR_FORMATTING_FAILURE = -45,
@@ -85,15 +97,18 @@
VAR_OK = 0
} var_rc_t;
+/* opaque data type */
struct var_st;
typedef struct var_st var_t;
+/* var_config() modes */
typedef enum {
VAR_CONFIG_SYNTAX,
VAR_CONFIG_CB_VALUE,
VAR_CONFIG_CB_OPERATION
} var_config_t;
+/* VAR_CONFIG_SYNTAX type */
typedef struct {
char escape; /* default: '\' */
char delim_init; /* default: '$' */
@@ -105,22 +120,26 @@
char *name_chars; /* default: "a-zA-Z0-9_" */
} var_syntax_t;
+/* VAR_CONFIG_CB_VALUE type */
typedef var_rc_t (*var_cb_value_t)(
var_t *var, void *ctx,
- const char *var_ptr, size_t var_len, int var_idx,
+ const char *var_ptr, size_t var_len, int var_idx,
const char **val_ptr, size_t *val_len, size_t *val_size
);
+/* VAR_CONFIG_CB_OPERATION type */
typedef var_rc_t (*var_cb_operation_t)(
var_t *var, void *ctx,
- const char *op_ptr, size_t op_len,
- const char *arg_ptr, size_t arg_len,
- const char *val_ptr, size_t val_len,
+ const char *op_ptr, size_t op_len,
+ const char *arg_ptr, size_t arg_len,
+ const char *val_ptr, size_t val_len,
const char **out_ptr, size_t *out_len, size_t *out_size
);
+/* library API identification */
extern const char var_id[];
+/* library API functions */
var_rc_t var_create (var_t **var);
var_rc_t var_destroy (var_t *var);
var_rc_t var_config (var_t *var, var_config_t mode, ...);
@@ -130,5 +149,7 @@
var_rc_t var_format (var_t *var, char **dst_ptr, int force_expand, const char *fmt, ...);
var_rc_t var_strerror (var_t *var, var_rc_t rc, char **str);
+DECLARATION_END
+
#endif /* __VAR_H__ */
|