summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-14 21:52:55 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-04-14 21:52:55 -0400
commit6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 (patch)
tree86d7c281bcdbf67eb53cee064aa905e740ec5ccf /include
downloadnastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.tar.gz
nastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.zip
Initial import
Diffstat (limited to 'include')
-rw-r--r--include/.svn/README.txt2
-rw-r--r--include/.svn/empty-file0
-rw-r--r--include/.svn/entries67
-rw-r--r--include/.svn/format1
-rw-r--r--include/.svn/prop-base/compat.h.svn-base1
-rw-r--r--include/.svn/prop-base/conf.h.svn-base1
-rw-r--r--include/.svn/prop-base/config.h.svn-base1
-rw-r--r--include/.svn/prop-base/nastd.h.svn-base1
-rw-r--r--include/.svn/prop-base/nastipc.h.svn-base1
-rw-r--r--include/.svn/prop-base/version.h.svn-base1
-rw-r--r--include/.svn/props/compat.h.svn-work1
-rw-r--r--include/.svn/props/conf.h.svn-work1
-rw-r--r--include/.svn/props/config.h.svn-work1
-rw-r--r--include/.svn/props/nastd.h.svn-work1
-rw-r--r--include/.svn/props/nastipc.h.svn-work1
-rw-r--r--include/.svn/props/version.h.svn-work1
-rw-r--r--include/.svn/text-base/compat.h.svn-base83
-rw-r--r--include/.svn/text-base/conf.h.svn-base16
-rw-r--r--include/.svn/text-base/config.h.svn-base40
-rw-r--r--include/.svn/text-base/nastd.h.svn-base85
-rw-r--r--include/.svn/text-base/nastipc.h.svn-base69
-rw-r--r--include/.svn/text-base/version.h.svn-base8
-rw-r--r--include/compat.h83
-rw-r--r--include/conf.h16
-rw-r--r--include/config.h40
-rw-r--r--include/nastd.h85
-rw-r--r--include/nastipc.h69
-rw-r--r--include/version.h8
28 files changed, 684 insertions, 0 deletions
diff --git a/include/.svn/README.txt b/include/.svn/README.txt
new file mode 100644
index 0000000..271a8ce
--- /dev/null
+++ b/include/.svn/README.txt
@@ -0,0 +1,2 @@
+This is a Subversion working copy administrative directory.
+Visit http://subversion.tigris.org/ for more information.
diff --git a/include/.svn/empty-file b/include/.svn/empty-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/.svn/empty-file
diff --git a/include/.svn/entries b/include/.svn/entries
new file mode 100644
index 0000000..e9a15b6
--- /dev/null
+++ b/include/.svn/entries
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wc-entries
+ xmlns="svn:">
+<entry
+ committed-rev="1"
+ name=""
+ committed-date="2005-12-08T17:32:07.572093Z"
+ url="svn+ssh://coleridge/svn/nastd/trunk/include"
+ last-author="bjc"
+ kind="dir"
+ uuid="2641c99b-6c07-0410-920d-927397d2d5d0"
+ revision="8"/>
+<entry
+ committed-rev="1"
+ name="nastd.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="a2a8507454598351d2fb4d92de8fac34"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:47.000000Z"/>
+<entry
+ committed-rev="1"
+ name="nastipc.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="c9c5a4de31ca1526065fba75540ca47d"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:48.000000Z"/>
+<entry
+ committed-rev="1"
+ name="compat.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="59e26d4dfdabe5879df3b1d38bc20380"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:48.000000Z"/>
+<entry
+ committed-rev="1"
+ name="conf.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="687df4cd84fcc53ab4edb6cb1bc967e0"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:48.000000Z"/>
+<entry
+ committed-rev="1"
+ name="config.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="6ff11b17126158149127110856fcab5d"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:48.000000Z"/>
+<entry
+ committed-rev="1"
+ name="version.h"
+ text-time="2005-12-24T00:00:48.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="c8e8460535f050ccc9e1a8024b65afde"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:48.000000Z"/>
+</wc-entries>
diff --git a/include/.svn/format b/include/.svn/format
new file mode 100644
index 0000000..b8626c4
--- /dev/null
+++ b/include/.svn/format
@@ -0,0 +1 @@
+4
diff --git a/include/.svn/prop-base/compat.h.svn-base b/include/.svn/prop-base/compat.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/compat.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/prop-base/conf.h.svn-base b/include/.svn/prop-base/conf.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/conf.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/prop-base/config.h.svn-base b/include/.svn/prop-base/config.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/config.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/prop-base/nastd.h.svn-base b/include/.svn/prop-base/nastd.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/nastd.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/prop-base/nastipc.h.svn-base b/include/.svn/prop-base/nastipc.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/nastipc.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/prop-base/version.h.svn-base b/include/.svn/prop-base/version.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/prop-base/version.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/compat.h.svn-work b/include/.svn/props/compat.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/compat.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/conf.h.svn-work b/include/.svn/props/conf.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/conf.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/config.h.svn-work b/include/.svn/props/config.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/config.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/nastd.h.svn-work b/include/.svn/props/nastd.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/nastd.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/nastipc.h.svn-work b/include/.svn/props/nastipc.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/nastipc.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/props/version.h.svn-work b/include/.svn/props/version.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/include/.svn/props/version.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/include/.svn/text-base/compat.h.svn-base b/include/.svn/text-base/compat.h.svn-base
new file mode 100644
index 0000000..3d1e3e6
--- /dev/null
+++ b/include/.svn/text-base/compat.h.svn-base
@@ -0,0 +1,83 @@
+/* $Id: compat.h,v 1.4 2000/03/21 19:06:58 shmit Exp $ */
+
+#ifndef COMPAT_H
+# define COMPAT_H
+
+#include <netdb.h>
+#include <syslog.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#if __GNUC__
+#define RCSID(x) static const char rcsid[] __attribute__((__unused__)) = x
+#else
+#define RCSID(x) static const char rcsid[] = x
+#endif
+
+#if OS_SOLARIS
+#define NEED_SNPRINTF 1
+#define NEED_SHADOW 1
+#define NEED_CRYPT 1
+#define NEED_SETPROCTITLE 1
+#define NEED_STRINGS 1
+
+#if SOLARIS_55
+#define NEED_CRYPT 1
+#include <pthread.h>
+#endif
+#endif /* OS_SOLARIS */
+
+#if OS_FREEBSD
+#include <libutil.h>
+
+#if FREEBSD_2
+typedef u_int32_t uint32_t;
+#endif /* FREEBSD_2 */
+#endif /* OS_FREEBSD */
+
+#if OS_LINUX
+#define NEED_SETPROCTITLE 1
+#endif /* OS_LINUX */
+
+#ifndef LOG_PERROR
+#define LOG_PERROR 0
+#endif
+
+#ifndef IPPORT_HIFIRSTAUTO
+#define IPPORT_HIFIRSTAUTO 49152
+#endif
+
+#ifndef IPPORT_HILASTAUTO
+#define IPPORT_HILASTAUTO 65535
+#endif
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 1024
+#endif
+
+#if NEED_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
+#if NEED_SNPRINTF
+int snprintf(char *str, size_t size, const char *fmt, ...);
+#endif
+
+#if NEED_MEMCPY
+void *memcpy(void *dst, const void *src, size_t len);
+#endif
+
+#if NEED_MEMSET
+void *memcpy(void *dst, char c, size_t len);
+#endif
+
+#if NEED_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
+#endif
diff --git a/include/.svn/text-base/conf.h.svn-base b/include/.svn/text-base/conf.h.svn-base
new file mode 100644
index 0000000..1b6ed37
--- /dev/null
+++ b/include/.svn/text-base/conf.h.svn-base
@@ -0,0 +1,16 @@
+/* $Id: conf.h,v 1.6 2000/11/15 20:20:50 shmit Exp $ */
+
+#ifndef CONF_H
+#define CONF_H
+
+#include <compat.h>
+#include <version.h>
+
+#define PERIODICITY 30 /* How many seconds between
+ periodic functions. */
+
+#ifndef DATADIR
+#define DATADIR "/home/shmit/libdata/nastd"
+#endif
+
+#endif
diff --git a/include/.svn/text-base/config.h.svn-base b/include/.svn/text-base/config.h.svn-base
new file mode 100644
index 0000000..36d3611
--- /dev/null
+++ b/include/.svn/text-base/config.h.svn-base
@@ -0,0 +1,40 @@
+/* $Id: config.h,v 1.3 2001/11/09 15:54:37 shmit Exp $ */
+
+#ifndef CONFIG_H
+# define CONFIG_H
+
+enum data_type { NUMBER, STRING, ARRAY, DICTIONARY };
+
+struct conf_entry {
+ char *name;
+ void *data;
+ int namelen, datalen;
+ enum data_type type;
+ int num_entries;
+};
+typedef struct conf_entry conf_entry_t;
+
+struct nast_config {
+ char *description;
+ char *nast_dir;
+ char *nast_sock;
+ char *nast_cdb_file;
+ char *mysql_host;
+ char *mysql_user;
+ char *mysql_pass;
+ int nofork_flag;
+ int null_cache_timeout;
+ int tcp_port;
+};
+
+extern struct nast_config config;
+
+int config_init();
+void config_delete();
+void config_setdefaults();
+void *config_find(void *root_node, const char *name, enum data_type *type);
+void *config_arrayitemat(void *array, int index, enum data_type *type);
+void *config_dictitemat(void *dict, const char *name, enum data_type *type);
+void *getdata(void *itemref, void *dst, enum data_type want_type);
+
+#endif
diff --git a/include/.svn/text-base/nastd.h.svn-base b/include/.svn/text-base/nastd.h.svn-base
new file mode 100644
index 0000000..b1fbaa4
--- /dev/null
+++ b/include/.svn/text-base/nastd.h.svn-base
@@ -0,0 +1,85 @@
+/* $Id: nastd.h,v 1.7 2001/10/29 11:17:12 shmit Exp $ */
+
+#ifndef NASTD_H
+#define NASTD_H
+
+enum _nast_bool { NASTFALSE = 0, NASTTRUE = 1 };
+typedef enum _nast_bool nast_bool;
+
+enum _errcodes {
+ NAST_OK = 0,
+ NAST_SERVER_GONE = 1,
+ NAST_NOMEM = 2,
+ NAST_UNKNOWN_RESPONSE = 3,
+ NAST_TIMEDOUT = 4,
+ NAST_UNKNOWN_OPT = 5,
+ NAST_SERVER_ERR
+};
+typedef enum _errcodes errcodes;
+
+struct _nast_options {
+ nast_bool use_qcache;
+ nast_bool use_localdb;
+ nast_bool fallthrough_async;
+ nast_bool always_fallthrough;
+ nast_bool fail_once;
+ nast_bool no_fallthrough;
+};
+typedef struct _nast_options nast_options;
+
+struct _nast_string_t {
+ char *strdata;
+ int strlen;
+};
+typedef struct _nast_string_t nast_string_t;
+
+struct _nast_array {
+ int nitems;
+ nast_string_t **items;
+};
+typedef struct _nast_array nast_array;
+
+struct _nast_response {
+ char *buffer;
+ char *errmsg;
+ errcodes errcode;
+ short bufflen;
+ unsigned short reqid;
+};
+typedef struct _nast_response nast_response;
+
+struct _nast_sphincter {
+ nast_response **responses;
+ void *lock;
+ int socket;
+ int nthreads;
+};
+typedef struct _nast_sphincter nasth;
+
+nasth *nast_sphincter_new(const char *sock_path);
+int nast_sphincter_connect(nasth *sphincter, const char *hostname,
+ unsigned short port, const char *username,
+ const char *password);
+void nast_sphincter_close(nasth *sphincter);
+
+nast_array *nast_get_result(nasth *sphincter);
+void nast_free_result(nast_array *result);
+
+nast_array *nast_array_new();
+int nast_array_add(nast_array *array, short len, const char *data);
+void nast_array_delete(nast_array *array);
+
+int nast_options_set(nasth *sphincter, nast_options *opts);
+int nast_options_get(nasth *sphincter, nast_options *opts);
+
+int nast_add(nasth *sphincter, const char *query);
+int nast_del(nasth *sphincter, const char *query);
+int nast_get(nasth *sphincter, const char *query);
+int nast_upd(nasth *sphincter, const char *key, nast_array *valarray);
+
+int nast_stats(nasth *sphincter);
+
+errcodes nast_geterr(nasth *sphincter);
+char *nast_errmsg(nasth *sphincter);
+
+#endif
diff --git a/include/.svn/text-base/nastipc.h.svn-base b/include/.svn/text-base/nastipc.h.svn-base
new file mode 100644
index 0000000..7309e8b
--- /dev/null
+++ b/include/.svn/text-base/nastipc.h.svn-base
@@ -0,0 +1,69 @@
+/* $Id: nastipc.h,v 1.3 2001/01/19 00:29:26 shmit Exp $ */
+
+#ifndef NASTIPC_H
+#define NASTIPC_H
+
+#define NASTHOLE "/tmp/nastd.sock"
+
+/* Protocol section */
+
+/*
+ * Send NASTESC to start a new command. The next byte specifies the
+ * type of command.
+ */
+#define NASTCMD '\xff'
+
+/*
+ * Commands, prefixed by NASTCMD.
+ */
+#define NASTADD '\x01'
+#define NASTDEL '\x02'
+#define NASTUPD '\x03'
+#define NASTGET '\x04'
+#define NASTDIE '\x0f'
+
+/* Commands for server options. */
+#define NASTOPTGET '\x10'
+#define NASTOPTSET '\x11'
+
+/* Command to get stats. */
+#define NASTSTATS '\x20'
+
+/* Server -> client responses. These can be postfixed with a string. */
+#define NASTOK '\xf1'
+#define NASTERR '\xf2'
+#define NASTARG '\xe0'
+
+/* The quote character, for globbing multiple strings together. */
+#define NASTQUOTE '\xfe'
+
+/*
+ * The escape character, to send binary that may be interpereted
+ * incorrectly.
+ */
+#define NASTESC '\xfd'
+
+/* Item seperator, for returning multiple items in one response. */
+#define NASTSEP '\xfc'
+
+/*
+ * The options. Ass more get added to the protocol, just add them here.
+ * Do not dupe option numbers. That'd be bad.
+ * Use these after the NASTCMD NASTOPTGET sequence. All options require
+ * an argument. Most are true/false, but some will require other types.
+ * Check nastd.h for option types.
+ * (e.g.: NASTCMD NASTOPTGET OPTQCACHE OPTFALSE - don't use the query cache)
+ * (e.g.: NASTCMD NASTOPTGET OPTNTHREADS 0x10 - allocate 16 threads)
+ */
+#define OPTFALSE '\x00'
+#define OPTTRUE '\x01'
+
+#define OPTQCACHE '\x01'
+#define OPTLOCALDB '\x02'
+#define OPTFALLASYNC '\x03'
+#define OPTALWAYSFALL '\x04'
+#define OPTFAILONCE '\x05'
+#define OPTNTHREADS '\x06'
+#define OPTNOFALLTHROUGH '\x07'
+
+#endif
diff --git a/include/.svn/text-base/version.h.svn-base b/include/.svn/text-base/version.h.svn-base
new file mode 100644
index 0000000..efd9441
--- /dev/null
+++ b/include/.svn/text-base/version.h.svn-base
@@ -0,0 +1,8 @@
+/* $Id: version.h,v 1.5 2001/05/30 21:00:12 shmit Exp $ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define VERSION "nast 1.2.0-devel $Date: 2001/05/30 21:00:12 $"
+
+#endif
diff --git a/include/compat.h b/include/compat.h
new file mode 100644
index 0000000..3d1e3e6
--- /dev/null
+++ b/include/compat.h
@@ -0,0 +1,83 @@
+/* $Id: compat.h,v 1.4 2000/03/21 19:06:58 shmit Exp $ */
+
+#ifndef COMPAT_H
+# define COMPAT_H
+
+#include <netdb.h>
+#include <syslog.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#if __GNUC__
+#define RCSID(x) static const char rcsid[] __attribute__((__unused__)) = x
+#else
+#define RCSID(x) static const char rcsid[] = x
+#endif
+
+#if OS_SOLARIS
+#define NEED_SNPRINTF 1
+#define NEED_SHADOW 1
+#define NEED_CRYPT 1
+#define NEED_SETPROCTITLE 1
+#define NEED_STRINGS 1
+
+#if SOLARIS_55
+#define NEED_CRYPT 1
+#include <pthread.h>
+#endif
+#endif /* OS_SOLARIS */
+
+#if OS_FREEBSD
+#include <libutil.h>
+
+#if FREEBSD_2
+typedef u_int32_t uint32_t;
+#endif /* FREEBSD_2 */
+#endif /* OS_FREEBSD */
+
+#if OS_LINUX
+#define NEED_SETPROCTITLE 1
+#endif /* OS_LINUX */
+
+#ifndef LOG_PERROR
+#define LOG_PERROR 0
+#endif
+
+#ifndef IPPORT_HIFIRSTAUTO
+#define IPPORT_HIFIRSTAUTO 49152
+#endif
+
+#ifndef IPPORT_HILASTAUTO
+#define IPPORT_HILASTAUTO 65535
+#endif
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 1024
+#endif
+
+#if NEED_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
+#if NEED_SNPRINTF
+int snprintf(char *str, size_t size, const char *fmt, ...);
+#endif
+
+#if NEED_MEMCPY
+void *memcpy(void *dst, const void *src, size_t len);
+#endif
+
+#if NEED_MEMSET
+void *memcpy(void *dst, char c, size_t len);
+#endif
+
+#if NEED_SETPROCTITLE
+void setproctitle(const char *fmt, ...);
+#endif
+
+#endif
diff --git a/include/conf.h b/include/conf.h
new file mode 100644
index 0000000..1b6ed37
--- /dev/null
+++ b/include/conf.h
@@ -0,0 +1,16 @@
+/* $Id: conf.h,v 1.6 2000/11/15 20:20:50 shmit Exp $ */
+
+#ifndef CONF_H
+#define CONF_H
+
+#include <compat.h>
+#include <version.h>
+
+#define PERIODICITY 30 /* How many seconds between
+ periodic functions. */
+
+#ifndef DATADIR
+#define DATADIR "/home/shmit/libdata/nastd"
+#endif
+
+#endif
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 0000000..36d3611
--- /dev/null
+++ b/include/config.h
@@ -0,0 +1,40 @@
+/* $Id: config.h,v 1.3 2001/11/09 15:54:37 shmit Exp $ */
+
+#ifndef CONFIG_H
+# define CONFIG_H
+
+enum data_type { NUMBER, STRING, ARRAY, DICTIONARY };
+
+struct conf_entry {
+ char *name;
+ void *data;
+ int namelen, datalen;
+ enum data_type type;
+ int num_entries;
+};
+typedef struct conf_entry conf_entry_t;
+
+struct nast_config {
+ char *description;
+ char *nast_dir;
+ char *nast_sock;
+ char *nast_cdb_file;
+ char *mysql_host;
+ char *mysql_user;
+ char *mysql_pass;
+ int nofork_flag;
+ int null_cache_timeout;
+ int tcp_port;
+};
+
+extern struct nast_config config;
+
+int config_init();
+void config_delete();
+void config_setdefaults();
+void *config_find(void *root_node, const char *name, enum data_type *type);
+void *config_arrayitemat(void *array, int index, enum data_type *type);
+void *config_dictitemat(void *dict, const char *name, enum data_type *type);
+void *getdata(void *itemref, void *dst, enum data_type want_type);
+
+#endif
diff --git a/include/nastd.h b/include/nastd.h
new file mode 100644
index 0000000..b1fbaa4
--- /dev/null
+++ b/include/nastd.h
@@ -0,0 +1,85 @@
+/* $Id: nastd.h,v 1.7 2001/10/29 11:17:12 shmit Exp $ */
+
+#ifndef NASTD_H
+#define NASTD_H
+
+enum _nast_bool { NASTFALSE = 0, NASTTRUE = 1 };
+typedef enum _nast_bool nast_bool;
+
+enum _errcodes {
+ NAST_OK = 0,
+ NAST_SERVER_GONE = 1,
+ NAST_NOMEM = 2,
+ NAST_UNKNOWN_RESPONSE = 3,
+ NAST_TIMEDOUT = 4,
+ NAST_UNKNOWN_OPT = 5,
+ NAST_SERVER_ERR
+};
+typedef enum _errcodes errcodes;
+
+struct _nast_options {
+ nast_bool use_qcache;
+ nast_bool use_localdb;
+ nast_bool fallthrough_async;
+ nast_bool always_fallthrough;
+ nast_bool fail_once;
+ nast_bool no_fallthrough;
+};
+typedef struct _nast_options nast_options;
+
+struct _nast_string_t {
+ char *strdata;
+ int strlen;
+};
+typedef struct _nast_string_t nast_string_t;
+
+struct _nast_array {
+ int nitems;
+ nast_string_t **items;
+};
+typedef struct _nast_array nast_array;
+
+struct _nast_response {
+ char *buffer;
+ char *errmsg;
+ errcodes errcode;
+ short bufflen;
+ unsigned short reqid;
+};
+typedef struct _nast_response nast_response;
+
+struct _nast_sphincter {
+ nast_response **responses;
+ void *lock;
+ int socket;
+ int nthreads;
+};
+typedef struct _nast_sphincter nasth;
+
+nasth *nast_sphincter_new(const char *sock_path);
+int nast_sphincter_connect(nasth *sphincter, const char *hostname,
+ unsigned short port, const char *username,
+ const char *password);
+void nast_sphincter_close(nasth *sphincter);
+
+nast_array *nast_get_result(nasth *sphincter);
+void nast_free_result(nast_array *result);
+
+nast_array *nast_array_new();
+int nast_array_add(nast_array *array, short len, const char *data);
+void nast_array_delete(nast_array *array);
+
+int nast_options_set(nasth *sphincter, nast_options *opts);
+int nast_options_get(nasth *sphincter, nast_options *opts);
+
+int nast_add(nasth *sphincter, const char *query);
+int nast_del(nasth *sphincter, const char *query);
+int nast_get(nasth *sphincter, const char *query);
+int nast_upd(nasth *sphincter, const char *key, nast_array *valarray);
+
+int nast_stats(nasth *sphincter);
+
+errcodes nast_geterr(nasth *sphincter);
+char *nast_errmsg(nasth *sphincter);
+
+#endif
diff --git a/include/nastipc.h b/include/nastipc.h
new file mode 100644
index 0000000..7309e8b
--- /dev/null
+++ b/include/nastipc.h
@@ -0,0 +1,69 @@
+/* $Id: nastipc.h,v 1.3 2001/01/19 00:29:26 shmit Exp $ */
+
+#ifndef NASTIPC_H
+#define NASTIPC_H
+
+#define NASTHOLE "/tmp/nastd.sock"
+
+/* Protocol section */
+
+/*
+ * Send NASTESC to start a new command. The next byte specifies the
+ * type of command.
+ */
+#define NASTCMD '\xff'
+
+/*
+ * Commands, prefixed by NASTCMD.
+ */
+#define NASTADD '\x01'
+#define NASTDEL '\x02'
+#define NASTUPD '\x03'
+#define NASTGET '\x04'
+#define NASTDIE '\x0f'
+
+/* Commands for server options. */
+#define NASTOPTGET '\x10'
+#define NASTOPTSET '\x11'
+
+/* Command to get stats. */
+#define NASTSTATS '\x20'
+
+/* Server -> client responses. These can be postfixed with a string. */
+#define NASTOK '\xf1'
+#define NASTERR '\xf2'
+#define NASTARG '\xe0'
+
+/* The quote character, for globbing multiple strings together. */
+#define NASTQUOTE '\xfe'
+
+/*
+ * The escape character, to send binary that may be interpereted
+ * incorrectly.
+ */
+#define NASTESC '\xfd'
+
+/* Item seperator, for returning multiple items in one response. */
+#define NASTSEP '\xfc'
+
+/*
+ * The options. Ass more get added to the protocol, just add them here.
+ * Do not dupe option numbers. That'd be bad.
+ * Use these after the NASTCMD NASTOPTGET sequence. All options require
+ * an argument. Most are true/false, but some will require other types.
+ * Check nastd.h for option types.
+ * (e.g.: NASTCMD NASTOPTGET OPTQCACHE OPTFALSE - don't use the query cache)
+ * (e.g.: NASTCMD NASTOPTGET OPTNTHREADS 0x10 - allocate 16 threads)
+ */
+#define OPTFALSE '\x00'
+#define OPTTRUE '\x01'
+
+#define OPTQCACHE '\x01'
+#define OPTLOCALDB '\x02'
+#define OPTFALLASYNC '\x03'
+#define OPTALWAYSFALL '\x04'
+#define OPTFAILONCE '\x05'
+#define OPTNTHREADS '\x06'
+#define OPTNOFALLTHROUGH '\x07'
+
+#endif
diff --git a/include/version.h b/include/version.h
new file mode 100644
index 0000000..efd9441
--- /dev/null
+++ b/include/version.h
@@ -0,0 +1,8 @@
+/* $Id: version.h,v 1.5 2001/05/30 21:00:12 shmit Exp $ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define VERSION "nast 1.2.0-devel $Date: 2001/05/30 21:00:12 $"
+
+#endif