Explorar o código

- rename database modules to use the 'db_' prefix

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3638 689a6050-402a-0410-94f2-e92a70836424
Henning Westerholt %!s(int64=17) %!d(string=hai) anos
achega
4a4cc74c10

+ 9 - 0
modules/db_flatstore/km_Makefile

@@ -0,0 +1,9 @@
+# $Id$
+#
+# WARNING: do not run this directly, it should be run by the master Makefile
+
+include ../../Makefile.defs
+auto_gen=
+NAME=flatstore.so
+
+include ../../Makefile.modules

+ 208 - 0
modules/db_flatstore/km_README

@@ -0,0 +1,208 @@
+Flatstore Module
+
+Jan Janak
+
+   FhG FOKUS
+
+Edited by
+
+Jan Janak
+
+   Copyright © 2004, 2005 FhG FOKUS
+     __________________________________________________________
+
+   Table of Contents
+   1. User's Guide
+
+        1.1. Overview
+
+              1.1.1. Rotating Log Files
+
+        1.2. Dependencies
+
+              1.2.1. OpenSER Modules
+              1.2.2. External Libraries or Applications
+
+        1.3. Exported Parameters
+
+              1.3.1. flush (integer)
+
+        1.4. Exported Functions
+        1.5. Exported MI Functions
+
+              1.5.1. flat_rotate
+
+   2. Developer's Guide
+   3. Frequently Asked Questions
+
+   List of Examples
+   1-1. Set "flush" parameter
+     __________________________________________________________
+
+Chapter 1. User's Guide
+
+1.1. Overview
+
+   Flatstore is one of so-called OpenSER database modules. It does
+   not export any functions executable from the configuration
+   scripts, but it exports a subset of functions from the database
+   API and thus other module can use it instead of, for example,
+   mysql module.
+
+   The module does not export all functions of the database API,
+   it supports only one function, insert. The module is limited
+   but very fast. It is especially suitable for storing accounting
+   information on sites with extremely high traffic. If MySQL is
+   too slow or if you get a huge amount of accounting data then
+   you can consider using this module. Note that the acc module is
+   the only module that was tested with flastore.
+
+   The format of the files produced by this module is plain text.
+   Each line consists of several fields, fields are separated by |
+   character. New information is always appended at the end of the
+   file, searching, deleting and updating of existing data is not
+   supported by the module.
+
+   The acc module can be configured to use flatstore module as
+   database backend using the db_url_parameter:
+modparam("acc", "db_url", "flatstore:/var/log/acc")
+
+   This configuration options tells acc module that it should use
+   the flatstore module and the flatstore module should create all
+   files in /var/log/acc directory. The directory must exist and
+   OpenSER processes must have permissions to create files in that
+   directory.
+
+   Name of files in that directory will follow the following
+   pattern:
+<table_name>_<process_name>.log
+
+   For example, entries writen by OpenSER process 8 into acc table
+   would be written in file acc_8.log. For each table there will
+   be several files, one file for every OpenSER process that wrote
+   some data into that table. The main reason why there are
+   several files for each table is that it is much faster to have
+   one file per process, because it does not require any locking
+   and thus OpenSER processes will not block each other. To get
+   the complete data for a table you can simply concatenate the
+   contents of files with the same table name but different
+   process id.
+     __________________________________________________________
+
+1.1.1. Rotating Log Files
+
+   There is a new OpenSER MI (management interface) command called
+   flat_rotate. When OpenSER receives the command then it will
+   close and reopen all files used by flatstore module. The
+   rotation itself has to be done by another application (such as
+   logrotate). Follow these steps to rotate files generated by
+   flatstore module:
+
+     * Rename the files that you want to rotate:
+cd /var/log/acc
+mv acc_1.log acc_1.log.20050605
+mv acc_2.log acc_2.log.20050605
+mv acc_4.log acc_3.log.20050605
+...
+
+       Note that at this point OpenSER will still be writing all
+       data into the renamed files.
+     * Send OpenSER the MI command to close and reopen the renamed
+       files. For example, using FIFO:
+openserctl fifo flat_rotate
+
+       This will force OpenSER to close the renamed files and open
+       new ones with original names, such as acc_1.log. New files
+       will be open at the point when OpenSER has some data to
+       write. It is normal that the files will be not created
+       immediately if there is no traffic on the proxy server.
+     * Move the renamed files somewhere else and process them.
+     __________________________________________________________
+
+1.2. Dependencies
+
+1.2.1. OpenSER Modules
+
+   The following modules must be loaded before this module:
+
+     * No dependencies on other OpenSER modules.
+     __________________________________________________________
+
+1.2.2. External Libraries or Applications
+
+   The following libraries or applications must be installed
+   before running OpenSER with this module loaded:
+
+     * None.
+     __________________________________________________________
+
+1.3. Exported Parameters
+
+1.3.1. flush (integer)
+
+   Enable or disable flushing after each write.
+
+   Default value is 1.
+
+   Example 1-1. Set "flush" parameter
+...
+modparam("flatstore", "flush", 0)
+...
+     __________________________________________________________
+
+1.4. Exported Functions
+
+   There are no function exported to routing script.
+     __________________________________________________________
+
+1.5. Exported MI Functions
+
+1.5.1. flat_rotate
+
+   It changes the name of the files where it is written.
+
+   Name: flat_rotate
+
+   Parameters: none
+
+   MI FIFO Command Format:
+                :flat_rotate:_reply_fifo_file_
+                _empty_line_
+     __________________________________________________________
+
+Chapter 2. Developer's Guide
+
+   The module implements the DB API.
+     __________________________________________________________
+
+Chapter 3. Frequently Asked Questions
+
+   3.1. Where can I find more about OpenSER?
+   3.2. Where can I post a question about this module?
+   3.3. How can I report a bug?
+
+   3.1. Where can I find more about OpenSER?
+
+   Take a look at http://openser.org/.
+
+   3.2. Where can I post a question about this module?
+
+   First at all check if your question was already answered on one
+   of our mailing lists:
+
+     * User Mailing List -
+       http://openser.org/cgi-bin/mailman/listinfo/users
+     * Developer Mailing List -
+       http://openser.org/cgi-bin/mailman/listinfo/devel
+
+   E-mails regarding any stable OpenSER release should be sent to
+   <[email protected]> and e-mails regarding development versions
+   should be sent to <[email protected]>.
+
+   If you want to keep the mail private, send it to
+   <[email protected]>.
+
+   3.3. How can I report a bug?
+
+   Please follow the guidelines provided at:
+   http://sourceforge.net/tracker/?group_id=139143.

+ 53 - 0
modules/db_flatstore/km_doc/flatstore.sgml

@@ -0,0 +1,53 @@
+<!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [
+
+
+<!ENTITY user SYSTEM "flatstore_user.sgml">
+<!ENTITY devel SYSTEM "flatstore_devel.sgml">
+<!ENTITY faq SYSTEM "flatstore_faq.sgml">
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../doc/entities.sgml">
+%docentities;
+
+]>
+
+<book>
+	<bookinfo>
+	<title>Flatstore Module</title>
+	<productname class="trade">&sername;</productname>
+	<authorgroup>
+		<author>
+		<firstname>Jan</firstname>
+		<surname>Janak</surname>
+		<affiliation><orgname>FhG FOKUS</orgname></affiliation>
+		<address>
+			<email>[email protected]</email>
+		</address>
+		</author>
+		<editor>
+		<firstname>Jan</firstname>
+		<surname>Janak</surname>
+		<address>
+			<email>[email protected]</email>
+		</address>
+		</editor>
+	</authorgroup>
+	<copyright>
+		<year>2004</year>
+		<year>2005</year>
+		<holder>FhG FOKUS</holder>
+	</copyright>
+	<revhistory>
+		<revision>
+		<revnumber>$Revision$</revnumber>
+		<date>$Date$</date>
+		</revision>
+	</revhistory>
+	</bookinfo>
+	<toc></toc>
+	
+	&user;
+	&devel;
+	&faq;
+	
+</book>

+ 22 - 0
modules/db_flatstore/km_doc/flatstore_devel.sgml

@@ -0,0 +1,22 @@
+<!-- Module Developer's Guide -->
+
+<chapter>
+	<chapterinfo>
+	<revhistory>
+		<revision>
+		<revnumber>$Revision$</revnumber>
+		<date>$Date$</date>
+		</revision>
+	</revhistory>
+	</chapterinfo>
+	<title>Developer's Guide</title>
+	<para>
+	The module implements the DB <acronym>API</acronym>.
+	</para>
+</chapter>
+
+<!-- Keep this element at the end of the file
+Local Variables:
+sgml-parent-document: ("exec.sgml" "book" "chapter")
+End:
+-->

+ 70 - 0
modules/db_flatstore/km_doc/flatstore_faq.sgml

@@ -0,0 +1,70 @@
+<!-- Module FAQ -->
+
+<chapter>
+	<chapterinfo>
+	<revhistory>
+		<revision>
+		<revnumber>$Revision$</revnumber>
+		<date>$Date$</date>
+		</revision>
+	</revhistory>
+	</chapterinfo>
+	<title>Frequently Asked Questions</title>
+	<qandaset defaultlabel="number">
+	<qandaentry>
+		<question>
+		<para>Where can I find more about OpenSER?</para>
+		</question>
+		<answer>
+		<para>
+			Take a look at &serhomelink;.
+		</para>
+		</answer>
+	</qandaentry>
+	<qandaentry>
+		<question>
+		<para>Where can I post a question about this module?</para>
+		</question>
+		<answer>
+		<para>
+			First at all check if your question was already answered on one of
+			our mailing lists: 
+		</para>
+		<itemizedlist>
+			<listitem>
+			<para>User Mailing List - &seruserslink;</para>
+			</listitem>
+			<listitem>
+			<para>Developer Mailing List - &serdevlink;</para>
+			</listitem>
+		</itemizedlist>
+		<para>
+			E-mails regarding any stable &ser; release should be sent to 
+			&serusersmail; and e-mails regarding development versions
+			should be sent to &serdevmail;.
+		</para>
+		<para>
+			If you want to keep the mail private, send it to 
+			&serhelpmail;.
+		</para>
+		</answer>
+	</qandaentry>
+	<qandaentry>
+		<question>
+		<para>How can I report a bug?</para>
+		</question>
+		<answer>
+		<para>
+			Please follow the guidelines provided at:
+			&serbugslink;.
+		</para>
+		</answer>
+	</qandaentry>
+	</qandaset>
+</chapter>
+
+<!-- Keep this element at the end of the file
+Local Variables:
+sgml-parent-document: ("flatstore.sgml" "Book" "chapter")
+End:
+-->

+ 206 - 0
modules/db_flatstore/km_doc/flatstore_user.sgml

@@ -0,0 +1,206 @@
+<!-- Module User's Guide -->
+
+<chapter>
+	<chapterinfo>
+	<revhistory>
+		<revision>
+		<revnumber>$Revision$</revnumber>
+		<date>$Date$</date>
+		</revision>
+	</revhistory>
+	</chapterinfo>
+	<title>User's Guide</title>
+	
+	<section>
+	<title>Overview</title>
+	<para>
+		Flatstore is one of so-called &ser; database modules. It does not
+		export any functions executable from the configuration scripts, but
+		it exports a subset of functions from the database API and thus
+		other module can use it instead of, for example, mysql module.
+	</para>
+	<para>
+		The module does not export all functions of the database API, it
+		supports only one function, insert. The module is limited but very
+		fast. It is especially suitable for storing accounting information
+		on sites with extremely high traffic. If MySQL is too slow or if
+		you get a huge amount of accounting data then you can consider
+		using this module. Note that the acc module is the only module that
+		was tested with flastore.
+	</para>
+	<para>
+		The format of the files produced by this module is plain text. Each
+		line consists of several fields, fields are separated by |
+		character. New information is always appended at the end of the
+		file, searching, deleting and updating of existing data is not
+		supported by the module.
+	</para>
+	<para>
+		The acc module can be configured to use flatstore module as
+		database backend using the db_url_parameter:
+	</para>
+	<programlisting>
+modparam("acc", "db_url", "flatstore:/var/log/acc")
+</programlisting>
+	<para>
+		This configuration options tells acc module that it should use the
+		flatstore module and the flatstore module should create all files
+		in /var/log/acc directory. The directory must exist and &ser;
+		processes must have permissions to create files in that directory.
+	</para>
+	<para>
+		Name of files in that directory will follow the following pattern:
+	</para>
+	<programlisting>
+&lt;table_name&gt;_&lt;process_name&gt;.log
+</programlisting>
+	<para>
+		For example, entries writen by &ser; process 8 into acc table would
+		be written in file acc_8.log. For each table there will be several
+		files, one file for every &ser; process that wrote some data into
+		that table. The main reason why there are several files for each
+		table is that it is much faster to have one file per process,
+		because it does not require any locking and thus &ser; processes will
+		not block each other. To get the complete data for a table you can
+		simply concatenate the contents of files with the same table name
+		but different process id.
+	</para>
+	<section id="rotating">
+		<title>Rotating Log Files</title>
+		<para>
+		There is a new &ser; MI (management interface) command called 
+		flat_rotate.
+		When &ser; receives the command then it will close and reopen all
+		files used by flatstore module. The rotation itself has to be
+		done by another application (such as logrotate). Follow these
+		steps to rotate files generated by flatstore module:
+		</para>
+		<itemizedlist>
+		<listitem>
+			<para>
+			Rename the files that you want to rotate:
+			<screen>
+cd /var/log/acc
+mv acc_1.log acc_1.log.20050605
+mv acc_2.log acc_2.log.20050605
+mv acc_4.log acc_3.log.20050605
+...
+			</screen>
+			Note that at this point &ser; will still be writing all
+			data into the renamed files.
+			</para>
+		</listitem>
+		<listitem>
+			<para>
+			Send &ser; the MI command to close and reopen the
+			renamed files. For example, using FIFO:
+			<screen>
+openserctl fifo flat_rotate
+			</screen>
+			This will force &ser; to close the renamed files and open
+			new ones with original names, such as
+			<filename>acc_1.log</filename>. New files will be open
+			at the point when &ser; has some data to write. It is
+			normal that the files will be not created immediately
+			if there is no traffic on the proxy server.
+			</para>
+		</listitem>
+		<listitem>
+			<para>
+			Move the renamed files somewhere else and process them.
+			</para>
+		</listitem>
+		</itemizedlist>
+	</section>
+	</section>
+
+	<section>
+	<title>Dependencies</title>
+	<section>
+		<title>&ser; Modules</title>
+		<para>
+		The following  modules must be loaded before this module:
+			<itemizedlist>
+			<listitem>
+			<para>
+				<emphasis>No dependencies on other &ser; modules</emphasis>.
+			</para>
+			</listitem>
+			</itemizedlist>
+		</para>
+	</section>
+	<section>
+		<title>External Libraries or Applications</title>
+		<para>
+		The following libraries or applications must be installed before running
+		&ser; with this module loaded:
+			<itemizedlist>
+			<listitem>
+			<para>
+				<emphasis>None</emphasis>.
+			</para>
+			</listitem>
+			</itemizedlist>
+		</para>
+	</section>
+	</section>
+
+	<section>
+	<title>Exported Parameters</title>
+	<section>
+		<title><varname>flush</varname> (integer)</title>
+		<para>
+		Enable or disable flushing after each write.
+		</para>
+		<para>
+		<emphasis>
+			Default value is 1.
+		</emphasis>
+		</para>
+		<example>
+		<title>Set <quote>flush</quote> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("flatstore", "flush", 0)
+...
+</programlisting>
+		</example>
+	</section>
+	</section>
+
+	<section>
+	<title>Exported Functions</title>
+	<para>
+	There are no function exported to routing script.
+	</para>
+	</section>
+	
+	<section>
+	<title>Exported MI Functions</title>
+	<section>
+		<title>
+		<function moreinfo="none">flat_rotate</function>
+		</title>
+		<para>
+		It changes the name of the files where it is written.
+		</para>
+		<para>
+		Name: <emphasis>flat_rotate</emphasis>
+		</para>
+		<para>Parameters: <emphasis>none</emphasis></para>
+ 		<para>
+		MI FIFO Command Format:
+		</para>
+        <programlisting  format="linespecific">
+		:flat_rotate:_reply_fifo_file_
+		_empty_line_
+		</programlisting>
+	</section>	
+    </section>
+</chapter>
+
+<!-- Keep this element at the end of the file
+Local Variables:
+sgml-parent-document: ("exec.sgml" "Book" "chapter")
+End:
+-->

+ 179 - 0
modules/db_flatstore/km_flat_con.c

@@ -0,0 +1,179 @@
+/* 
+ * $Id$
+ *
+ * Flastore module connection structure
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+#include <errno.h>
+#include "../../mem/mem.h"
+#include "../../dprint.h"
+#include "../../ut.h"
+#include "flatstore_mod.h"
+#include "flat_con.h"
+
+#define FILE_SUFFIX ".log"
+#define FILE_SUFFIX_LEN (sizeof(FILE_SUFFIX) - 1)
+
+/* returns a pkg_malloc'ed file name */
+static char* get_name(struct flat_id* id)
+{
+	char* buf;
+	int buf_len;
+	char* num, *ptr;
+	int num_len;
+	int total_len;
+
+	buf_len=pathmax();
+	if (!id) {
+		LM_ERR("invalid parameter value\n");
+		return 0;
+	}
+	total_len=id->dir.len+1 /* / */+id->table.len+1 /* _ */+
+				FILE_SUFFIX_LEN+1 /* \0 */; /* without pid*/
+	if (buf_len<total_len){
+		LM_ERR("the path is too long (%d and PATHMAX is %d)\n",
+					total_len, buf_len);
+		return 0;
+	}
+	
+	buf=pkg_malloc(buf_len);
+	if (buf==0){
+		LM_ERR("pkg memory allocation failure\n");
+		return 0;
+	}
+
+	ptr = buf;
+
+	memcpy(ptr, id->dir.s, id->dir.len);
+	ptr += id->dir.len;
+	*ptr++ = '/';
+
+	memcpy(ptr, id->table.s, id->table.len);
+	ptr += id->table.len;
+
+	*ptr++ = '_';
+	
+	num = int2str(flat_pid, &num_len);
+	if (buf_len<(total_len+num_len)){
+		LM_ERR("the path is too long (%d and PATHMAX is"
+				" %d)\n", total_len+num_len, buf_len);
+		pkg_free(buf);
+		return 0;
+	}
+	memcpy(ptr, num, num_len);
+	ptr += num_len;
+
+	memcpy(ptr, FILE_SUFFIX, FILE_SUFFIX_LEN);
+	ptr += FILE_SUFFIX_LEN;
+
+	*ptr = '\0';
+	return buf;
+}
+
+
+struct flat_con* flat_new_connection(struct flat_id* id)
+{
+	char* fn;
+
+	struct flat_con* res;
+
+	if (!id) {
+		LM_ERR("invalid parameter value\n");
+		return 0;
+	}
+
+	res = (struct flat_con*)pkg_malloc(sizeof(struct flat_con));
+	if (!res) {
+		LM_ERR("no pkg memory left\n");
+		return 0;
+	}
+
+	memset(res, 0, sizeof(struct flat_con));
+	res->ref = 1;
+	
+	res->id = id;
+
+	fn = get_name(id);
+	if (fn==0){
+		LM_ERR("get_name() failed\n");
+		return 0;
+	}
+
+	res->file = fopen(fn, "a");
+	pkg_free(fn); /* we don't need fn anymore */
+	if (!res->file) {
+		LM_ERR(" %s\n", strerror(errno));
+		pkg_free(res);
+		return 0;
+	}
+	
+	return res;
+}
+
+
+/*
+ * Close the connection and release memory
+ */
+void flat_free_connection(struct flat_con* con)
+{
+	if (!con) return;
+	if (con->id) free_flat_id(con->id);
+	if (con->file) {
+		fclose(con->file);
+	}
+	pkg_free(con);
+}
+
+
+/*
+ * Reopen a connection
+ */
+int flat_reopen_connection(struct flat_con* con)
+{
+	char* fn;
+
+	if (!con) {
+		LM_ERR("invalid parameter value\n");
+		return -1;
+	}
+
+	if (con->file) {
+		fclose(con->file);
+		con->file = 0;
+
+		fn = get_name(con->id);
+		if (fn == 0) {
+			LM_ERR("failed to get_name\n");
+			return -1;
+		}
+
+		con->file = fopen(fn, "a");
+		pkg_free(fn);
+
+		if (!con->file) {
+			LM_ERR("invalid parameter value\n");
+			return -1;
+		}
+	}
+
+	return 0;
+}

+ 65 - 0
modules/db_flatstore/km_flat_con.h

@@ -0,0 +1,65 @@
+/* 
+ * $Id$
+ *
+ * Flatstore module connection structure
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _FLAT_CON_H
+#define _FLAT_CON_H
+
+#include <stdio.h>
+#include <time.h>
+#include "flat_id.h"
+
+struct flat_con {
+	struct flat_id* id;    /* Connection identifier */
+	int ref;               /* Reference count */
+	FILE* file;            /* File descriptor structure */
+	struct flat_con* next; /* Next connection in the pool */
+};
+
+
+/*
+ * Some convenience wrappers
+ */
+#define CON_FILE(db_con) (((struct flat_con*)((db_con)->tail))->file)
+
+
+/*
+ * Create a new connection structure,
+ * open the MySQL connection and set reference count to 1
+ */
+struct flat_con* flat_new_connection(struct flat_id* id);
+
+
+/*
+ * Close the connection and release memory
+ */
+void flat_free_connection(struct flat_con* con);
+
+
+/*
+ * Reopen a connection
+ */
+int flat_reopen_connection(struct flat_con* con);
+
+
+#endif /* _FLAT_CON_H */

+ 82 - 0
modules/db_flatstore/km_flat_id.c

@@ -0,0 +1,82 @@
+/* 
+ * $Id$
+ *
+ * Flatstore module connection identifier
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <string.h>
+#include "../../dprint.h"
+#include "../../mem/mem.h"
+#include "flat_id.h"
+
+
+
+/*
+ * Create a new connection identifier
+ */
+struct flat_id* new_flat_id(char* dir, char* table)
+{
+	struct flat_id* ptr;
+
+	if (!dir || !table) {
+		LM_ERR("invalid parameter(s)\n");
+		return 0;
+	}
+
+	ptr = (struct flat_id*)pkg_malloc(sizeof(struct flat_id));
+	if (!ptr) {
+		LM_ERR("no pkg memory left\n");
+		return 0;
+	}
+	memset(ptr, 0, sizeof(struct flat_id));
+
+	ptr->dir.s = dir;
+	ptr->dir.len = strlen(dir);
+	ptr->table.s = table;
+	ptr->table.len = strlen(table);
+
+	return ptr;
+}
+
+
+/*
+ * Compare two connection identifiers
+ */
+unsigned char cmp_flat_id(struct flat_id* id1, struct flat_id* id2)
+{
+	if (!id1 || !id2) return 0;
+	if (id1->dir.len != id2->dir.len) return 0;
+	if (id1->table.len != id2->table.len) return 0;
+
+	if (memcmp(id1->dir.s, id2->dir.s, id1->dir.len)) return 0;
+	if (memcmp(id1->table.s, id2->table.s, id1->table.len)) return 0;
+	return 1;
+}
+
+
+/*
+ * Free a connection identifier
+ */
+void free_flat_id(struct flat_id* id)
+{
+	if (!id) return;
+	pkg_free(id);
+}

+ 55 - 0
modules/db_flatstore/km_flat_id.h

@@ -0,0 +1,55 @@
+/* 
+ * $Id$
+ *
+ * Flatstore connection identifier
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _FLAT_ID_H
+#define _FLAT_ID_H
+
+#include "../../str.h"
+
+
+struct flat_id {
+	str dir;   /* Database directory */ 
+	str table; /* Name of table */
+};
+
+
+/*
+ * Create a new connection identifier
+ */
+struct flat_id* new_flat_id(char* dir, char* table);
+
+
+/*
+ * Compare two connection identifiers
+ */
+unsigned char cmp_flat_id(struct flat_id* id1, struct flat_id* id2);
+
+
+/*
+ * Free a connection identifier
+ */
+void free_flat_id(struct flat_id* id);
+
+
+#endif /* _FLAT_ID_H */

+ 40 - 0
modules/db_flatstore/km_flat_mi.c

@@ -0,0 +1,40 @@
+/* 
+ * $Id$ 
+ *
+ * Flatstore module MI interface
+ *
+ * Copyright (C) 2006 Voice Sistem SRL
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "flatstore_mod.h"
+#include "flat_mi.h"
+
+
+struct mi_root*  mi_flat_rotate_cmd(struct mi_root* cmd_tree, void* param)
+{
+	struct mi_root *rpl_tree;
+
+	rpl_tree = init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
+	if(rpl_tree == NULL)
+		return rpl_tree;
+
+	*flat_rotate = time(0);
+
+	return rpl_tree;
+}

+ 35 - 0
modules/db_flatstore/km_flat_mi.h

@@ -0,0 +1,35 @@
+/*
+ * $Id$ 
+ *
+ * Flatstore module MI interface
+ *
+ * Copyright (C) 2006 Voice Sistem RL
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _FLATSTORE_MI_H_
+#define _FLATSTORE_MI_H_
+
+#include "../../mi/mi.h"
+
+#define MI_FLAT_ROTATE "flat_rotate"
+
+struct mi_root*  mi_flat_rotate_cmd(struct mi_root* cmd, void* param);
+
+#endif /* _FLATSTORE_MI_H_ */
+

+ 152 - 0
modules/db_flatstore/km_flat_pool.c

@@ -0,0 +1,152 @@
+/* 
+ * $Id$
+ *
+ * Flatstore module connection pool
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <unistd.h>
+#include "../../dprint.h"
+#include "flat_pool.h"
+#include "flat_id.h"
+
+
+/* The head of the pool */
+static struct flat_con* pool = 0;
+
+/*
+ * Pid of the process that added the last
+ * connection to the pool. This is used to
+ * check for inherited database connections.
+ */
+static int pool_pid;
+
+
+
+/*
+ * Get a connection from the pool, reuse existing
+ * if possible, otherwise create a new one
+ */
+struct flat_con* flat_get_connection(char* dir, char* table)
+{
+	struct flat_id* id;
+	struct flat_con* ptr;
+	int pid;
+
+	if (!dir || !table) {
+		LM_ERR("invalid parameter value\n");
+		return 0;
+	}
+
+	pid = getpid();
+	if (pool && (pool_pid != pid)) {
+		LM_ERR("inherited open database connections, "
+				"this is not a good idea\n");
+		return 0;
+	}
+
+	pool_pid = pid;
+
+	id = new_flat_id(dir, table);
+	if (!id) return 0;
+
+	ptr = pool;
+	while (ptr) {
+		if (cmp_flat_id(id, ptr->id)) {
+			LM_DBG("connection found in the pool\n");
+			ptr->ref++;
+			free_flat_id(id);
+			return ptr;
+		}
+		ptr = ptr->next;
+	}
+
+	LM_DBG("connection not found in the pool\n");
+	ptr = flat_new_connection(id);
+	if (!ptr) {
+		free_flat_id(id);
+		return 0;
+	}
+
+	ptr->next = pool;
+	pool = ptr;
+	return ptr;
+}
+
+
+/*
+ * Release a connection, the connection will be left
+ * in the pool if ref count != 0, otherwise it
+ * will be delete completely
+ */
+void flat_release_connection(struct flat_con* con)
+{
+	struct flat_con* ptr;
+
+	if (!con) return;
+
+	if (con->ref > 1) {
+		     /* There are still other users, just
+		      * decrease the reference count and return
+		      */
+		LM_DBG("connection still kept in the pool\n");
+		con->ref--;
+		return;
+	}
+
+	LM_DBG("removing connection from the pool\n");
+
+	if (pool == con) {
+		pool = pool->next;
+	} else {
+		ptr = pool;
+		while(ptr) {
+			if (ptr->next == con) break;
+			ptr = ptr->next;
+		}
+		if (!ptr) {
+			LM_ERR("weird, connection not found in the pool\n");
+		} else {
+			     /* Remove the connection from the pool */
+			ptr->next = con->next;
+		}
+	}
+
+	flat_free_connection(con);
+}
+
+
+/*
+ * Close and reopen all opened connections
+ */
+int flat_rotate_logs(void)
+{
+	struct flat_con* ptr;
+
+	ptr = pool;
+	while(ptr) {
+		if (flat_reopen_connection(ptr)) {
+			return -1;
+		}
+		ptr = ptr->next;
+	}
+
+	return 0;
+}

+ 50 - 0
modules/db_flatstore/km_flat_pool.h

@@ -0,0 +1,50 @@
+/* 
+ * $Id$
+ *
+ * Flatstore module connection pool
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _FLAT_POOL_H
+#define _FLAT_POOL_H
+
+#include "flat_con.h"
+
+/*
+ * Get a connection from the pool, reuse existing
+ * if possible, otherwise create a new one
+ */
+struct flat_con* flat_get_connection(char* dir, char* table);
+
+
+/*
+ * Release a connection, the connection will be left
+ * in the pool if ref count != 0, otherwise it
+ * will be delete completely
+ */
+void flat_release_connection(struct flat_con* con);
+
+
+/*
+ * Close and reopen all opened connections
+ */
+int flat_rotate_logs(void);
+
+#endif /* _FLAT_POOL_H */

+ 217 - 0
modules/db_flatstore/km_flatstore.c

@@ -0,0 +1,217 @@
+/* 
+ * $Id$ 
+ *
+ * Flatstore module interface
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * --------
+ *  2003-03-11  updated to the new module exports interface (andrei)
+ *  2003-03-16  flags export parameter added (janakj)
+ */
+
+#include <string.h>
+#include <ctype.h>
+#include "../../mem/mem.h"
+#include "../../dprint.h"
+#include "flat_pool.h"
+#include "flat_con.h"
+#include "flatstore_mod.h"
+#include "flatstore.h"
+
+
+static int parse_flat_url(const str* url, str* path)
+{
+	if (!url || !url->s || !path) {
+		LM_ERR("invalid parameter value\n");
+		return -1;
+	}
+	path->s = strchr(url->s, ':') + 1;
+	path->len = strlen(path->s);
+	return 0;
+}
+
+
+
+/*
+ * Initialize database module
+ * No function should be called before this
+ */
+db_con_t* flat_db_init(const str* url)
+{
+	db_con_t* res;
+
+	if (!url || !url->s) {
+		LM_ERR("invalid parameter value\n");
+		return 0;
+	}
+
+	/* We do not know the name of the table (and the name of the corresponding
+	 * file) at this point, we will simply store the path taken from the url 
+	 * parameter in the table variable, flat_use_table will then pick that 
+	 * value and open the file
+	 */
+	res = pkg_malloc(sizeof(db_con_t) + sizeof(struct flat_con*));
+	if (!res) {
+		LM_ERR("no pkg memory left\n");
+		return 0;
+	}
+	memset(res, 0, sizeof(db_con_t) + sizeof(struct flat_con*));
+
+	if (parse_flat_url(url, (str*)res->table) < 0) {
+		pkg_free(res);
+		return 0;
+	}
+
+	return res;
+}
+
+
+/*
+ * Store name of table that will be used by
+ * subsequent database functions
+ */
+int flat_use_table(db_con_t* h, const str* t)
+{
+	struct flat_con* con;
+
+	if (!h || !t || !t->s) {
+		LM_ERR("invalid parameter value\n");
+		return -1;
+	}
+
+	if (CON_TABLE(h)->s != t->s) {
+		if (CON_TAIL(h)) {
+			     /* Decrement the reference count
+			      * of the connection but do not remove
+			      * it from the connection pool
+			      */
+			con = (struct flat_con*)CON_TAIL(h);
+			con->ref--;
+
+		}
+
+		CON_TAIL(h) = (unsigned long)flat_get_connection((char*)CON_TABLE(h)->s, (char*)t->s);
+		if (!CON_TAIL(h)) {
+			return -1;
+		}
+	}
+	
+	return 0;
+}
+
+
+void flat_db_close(db_con_t* h)
+{
+	struct flat_con* con;
+
+	if (!h) {
+		LM_ERR("invalid parameter value\n");
+		return;
+	}
+
+	con = (struct flat_con*)CON_TAIL(h);
+
+	if (con) {
+		flat_release_connection(con);
+	}
+	pkg_free(h);
+}
+
+
+/*
+ * Insert a row into specified table
+ * h: structure representing database connection
+ * k: key names
+ * v: values of the keys
+ * n: number of key=value pairs
+ */
+int flat_db_insert(db_con_t* h, db_key_t* k, db_val_t* v, int n)
+{
+	FILE* f;
+	int i;
+	int l;
+	char *s, *p;
+
+	if (local_timestamp < *flat_rotate) {
+		flat_rotate_logs();
+		local_timestamp = *flat_rotate;
+	}
+
+	f = CON_FILE(h);
+	if (!f) {
+		LM_ERR("uninitialized connection\n");
+		return -1;
+	}
+
+	for(i = 0; i < n; i++) {
+		switch(VAL_TYPE(v + i)) {
+		case DB_INT:
+			fprintf(f, "%d", VAL_INT(v + i));
+			break;
+
+		case DB_DOUBLE:
+			fprintf(f, "%f", VAL_DOUBLE(v + i));
+			break;
+
+		case DB_STRING:
+			fprintf(f, "%s", VAL_STRING(v + i));
+			break;
+
+		case DB_STR:
+			fprintf(f, "%.*s", VAL_STR(v + i).len, VAL_STR(v + i).s);
+			break;
+
+		case DB_DATETIME:
+			fprintf(f, "%u", (unsigned int)VAL_TIME(v + i));
+			break;
+
+		case DB_BLOB:
+			l = VAL_BLOB(v+i).len;
+			s = p = VAL_BLOB(v+i).s;
+			while (l--) {
+				if ( !(isprint((int)*s) && *s != '\\' && *s != '|')) {
+					fprintf(f,"%.*s\\x%02X",(int)(s-p),p,(*s & 0xff));
+					p = s+1;
+				}
+				++s;
+			}
+			if (p!=s)
+				fprintf(f,"%.*s",(int)(s-p),p);
+			break;
+
+		case DB_BITMAP:
+			fprintf(f, "%u", VAL_BITMAP(v + i));
+			break;
+		}
+
+		if (i < (n - 1)) {
+			fprintf(f, "%c", *flat_delimiter);
+		}
+	}
+
+	fprintf(f, "\n");
+
+	if (flat_flush) {
+		fflush(f);
+	}
+
+	return 0;
+}

+ 66 - 0
modules/db_flatstore/km_flatstore.h

@@ -0,0 +1,66 @@
+/* 
+ * $Id$ 
+ *
+ * Flatstore module interface
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/*
+ * History:
+ * --------
+ *  2003-03-11  updated to the new module exports interface (andrei)
+ *  2003-03-16  flags export parameter added (janakj)
+ */
+
+#ifndef _FLATSTORE_H
+#define _FLATSTORE_H
+
+#include "../../db/db_val.h"
+#include "../../db/db_key.h"
+#include "../../db/db_con.h"
+
+
+/*
+ * Initialize database module
+ * No function should be called before this
+ */
+db_con_t* flat_db_init(const str* _url);
+
+
+/*
+ * Store name of table that will be used by
+ * subsequent database functions
+ */
+int flat_use_table(db_con_t* h, const str* t);
+
+
+void flat_db_close(db_con_t* h);
+
+
+/*
+ * Insert a row into specified table
+ * h: structure representing database connection
+ * k: key names
+ * v: values of the keys
+ * n: number of key=value pairs
+ */
+int flat_db_insert(db_con_t* h, db_key_t* k, db_val_t* v, int n);
+
+
+#endif /* _FLATSTORE_H */

+ 149 - 0
modules/db_flatstore/km_flatstore_mod.c

@@ -0,0 +1,149 @@
+/* 
+ * $Id$ 
+ *
+ * Flatstore module interface
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * --------
+ *  2003-03-11  updated to the new module exports interface (andrei)
+ *  2003-03-16  flags export parameter added (janakj)
+ */
+
+#include "../../sr_module.h"
+#include "../../mem/shm_mem.h"
+#include "flatstore.h"
+#include "flat_mi.h"
+#include "flatstore_mod.h"
+
+MODULE_VERSION
+
+static int child_init(int rank);
+
+static int mod_init(void);
+
+static void mod_destroy(void);
+
+
+/*
+ * Process number used in filenames
+ */
+int flat_pid;
+
+/*
+ * Should we flush after each write to the database ?
+ */
+int flat_flush = 1;
+
+
+/*
+ * Delimiter delimiting columns
+ */
+char* flat_delimiter = "|";
+
+
+/*
+ * Timestamp of the last log rotation request from
+ * the FIFO interface
+ */
+time_t* flat_rotate;
+
+time_t local_timestamp;
+
+/*
+ * Flatstore database module interface
+ */
+static cmd_export_t cmds[] = {
+	{"db_use_table",   (cmd_function)flat_use_table, 2, 0, 0, 0},
+	{"db_init",        (cmd_function)flat_db_init,   1, 0, 0, 0},
+	{"db_close",       (cmd_function)flat_db_close,  2, 0, 0, 0},
+	{"db_insert",      (cmd_function)flat_db_insert, 2, 0, 0, 0},
+	{0, 0, 0, 0, 0, 0}
+};
+
+
+/*
+ * Exported parameters
+ */
+static param_export_t params[] = {
+	{"flush", INT_PARAM, &flat_flush},
+	{0, 0, 0}
+};
+
+
+/*
+ * Exported parameters
+ */
+static mi_export_t mi_cmds[] = {
+	{ MI_FLAT_ROTATE, mi_flat_rotate_cmd,   MI_NO_INPUT_FLAG,  0,  0 },
+	{ 0, 0, 0, 0, 0}
+};
+
+struct module_exports exports = {
+	"flatstore",
+	DEFAULT_DLFLAGS, /* dlopen flags */
+	cmds,
+	params,      /*  module parameters */
+	0,           /* exported statistics */
+	mi_cmds,     /* exported MI functions */
+	0,           /* exported pseudo-variables */
+	0,           /* extra processes */
+	mod_init,    /* module initialization function */
+	0,           /* response function*/
+	mod_destroy, /* destroy function */
+	child_init   /* per-child init function */
+};
+
+
+static int mod_init(void)
+{
+	if (strlen(flat_delimiter) != 1) {
+		LM_ERR("delimiter has to be exactly one character\n");
+		return -1;
+	}
+
+	flat_rotate = (time_t*)shm_malloc(sizeof(time_t));
+	if (!flat_rotate) {
+		LM_ERR("no shared memory left\n");
+		return -1;
+	}
+
+	*flat_rotate = time(0);
+	local_timestamp = *flat_rotate;
+
+	return 0;
+}
+
+
+static void mod_destroy(void)
+{
+	if (flat_rotate) shm_free(flat_rotate);
+}
+
+
+static int child_init(int rank)
+{
+	if (rank <= 0) {
+		flat_pid = - rank;
+	} else {
+		flat_pid = rank - PROC_TCP_MAIN;
+	}
+	return 0;
+}

+ 67 - 0
modules/db_flatstore/km_flatstore_mod.h

@@ -0,0 +1,67 @@
+/* 
+ * $Id$ 
+ *
+ * Flatstore module interface
+ *
+ * Copyright (C) 2004 FhG Fokus
+ *
+ * This file is part of openser, a free SIP server.
+ *
+ * openser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * openser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * --------
+ *  2003-03-11  updated to the new module exports interface (andrei)
+ *  2003-03-16  flags export parameter added (janakj)
+ */
+
+#ifndef FLATSTORE_MOD_H
+#define FLATSTORE_MOD_H
+
+#include <time.h>
+
+/*
+ * Process number used in filenames
+ */
+extern int flat_pid;
+
+
+/*
+ * Should we flush after each write to the database ?
+ */
+extern int flat_flush;
+
+
+/*
+ * Delmiter delimiting columns
+ */
+extern char* flat_delimiter;
+
+
+/*
+ * The timestamp of log rotation request from
+ * the FIFO interface
+ */
+extern time_t* flat_rotate;
+
+
+/*
+ * Local timestamp marking the time of the
+ * last log rotation in the process
+ */
+extern time_t local_timestamp;
+
+
+#endif /* FLATSTORE_MOD_H */