aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Kropf <josh@slashdev.ca>2007-08-12 15:57:46 (GMT)
committerJosh Kropf <josh@slashdev.ca>2007-08-12 15:57:46 (GMT)
commit3b536ac041d5f3c5e303ad109e876cdd31904c19 (patch)
tree0049df212776df0aed518231769c954eae1eaa82
parenta9064e2310f8fc358ddc83f604464b9f7c3007c4 (diff)
downloadecho-server-3b536ac041d5f3c5e303ad109e876cdd31904c19.zip
echo-server-3b536ac041d5f3c5e303ad109e876cdd31904c19.tar.gz
echo-server-3b536ac041d5f3c5e303ad109e876cdd31904c19.tar.bz2
Modified project structure and added automake files
-rw-r--r--Makefile.am1
-rw-r--r--config/ac_cxx_have_stl.m443
-rw-r--r--config/ac_cxx_namespaces.m438
-rw-r--r--configure.in35
-rw-r--r--echo/Makefile.am5
-rw-r--r--echo/action.cpp (renamed from action/action.cpp)1
-rw-r--r--echo/action.h (renamed from action/action.h)10
-rw-r--r--echo/config.cpp (renamed from common/config.cpp)0
-rw-r--r--echo/config.h (renamed from common/config.h)10
-rw-r--r--src/Makefile.am4
-rw-r--r--src/dispatcher.cpp (renamed from fcgi/dispatcher.cpp)2
-rw-r--r--src/fcgi_io.cpp (renamed from fcgi/fcgi_io.cpp)3
-rw-r--r--src/fcgi_io.h (renamed from fcgi/fcgi_io.h)12
13 files changed, 147 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..aa1e0f2
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = echo src
diff --git a/config/ac_cxx_have_stl.m4 b/config/ac_cxx_have_stl.m4
new file mode 100644
index 0000000..93f5248
--- /dev/null
+++ b/config/ac_cxx_have_stl.m4
@@ -0,0 +1,43 @@
+##### http://autoconf-archive.cryp.to/ac_cxx_have_stl.html
+#
+# SYNOPSIS
+#
+# AC_CXX_HAVE_STL
+#
+# DESCRIPTION
+#
+# If the compiler supports the Standard Template Library, define
+# HAVE_STL.
+#
+# LAST MODIFICATION
+#
+# 2004-02-04
+#
+# COPYLEFT
+#
+# Copyright (c) 2004 Todd Veldhuizen
+# Copyright (c) 2004 Luc Maisonobe <luc@spaceroots.org>
+#
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved.
+
+AC_DEFUN([AC_CXX_HAVE_STL],
+[AC_CACHE_CHECK(whether the compiler supports Standard Template Library,
+ac_cv_cxx_have_stl,
+[AC_REQUIRE([AC_CXX_NAMESPACES])
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([#include <list>
+#include <deque>
+#ifdef HAVE_NAMESPACES
+using namespace std;
+#endif],[list<int> x; x.push_back(5);
+list<int>::iterator iter = x.begin(); if (iter != x.end()) ++iter; return 0;],
+ ac_cv_cxx_have_stl=yes, ac_cv_cxx_have_stl=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_have_stl" = yes; then
+ AC_DEFINE(HAVE_STL,,[define if the compiler supports Standard Template Library])
+fi
+])
diff --git a/config/ac_cxx_namespaces.m4 b/config/ac_cxx_namespaces.m4
new file mode 100644
index 0000000..424e885
--- /dev/null
+++ b/config/ac_cxx_namespaces.m4
@@ -0,0 +1,38 @@
+##### http://autoconf-archive.cryp.to/ac_cxx_namespaces.html
+#
+# SYNOPSIS
+#
+# AC_CXX_NAMESPACES
+#
+# DESCRIPTION
+#
+# If the compiler can prevent names clashes using namespaces, define
+# HAVE_NAMESPACES.
+#
+# LAST MODIFICATION
+#
+# 2004-02-04
+#
+# COPYLEFT
+#
+# Copyright (c) 2004 Todd Veldhuizen
+# Copyright (c) 2004 Luc Maisonobe <luc@spaceroots.org>
+#
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved.
+
+AC_DEFUN([AC_CXX_NAMESPACES],
+[AC_CACHE_CHECK(whether the compiler implements namespaces,
+ac_cv_cxx_namespaces,
+[AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
+ [using namespace Outer::Inner; return i;],
+ ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_namespaces" = yes; then
+ AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
+fi
+])
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..c5f8b6b
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,35 @@
+AC_INIT([Echo Server], [0.1.1], [josh@slashdev.ca])
+AC_CONFIG_AUX_DIR([config])
+AM_INIT_AUTOMAKE
+
+AC_PREREQ(2.60)
+
+# use c++ for checks
+AC_LANG_CPLUSPLUS
+
+AC_PROG_CXX
+AC_PROG_RANLIB
+
+AC_CXX_NAMESPACES
+AC_CXX_HAVE_STL
+
+# check for libraries, always error if not found
+
+# check will fail unless linked against lintl
+AC_CHECK_LIB([confuse], [cfg_init], ,
+ [AC_MSG_ERROR([Confuse library not found])], [-lintl])
+
+AC_CHECK_LIB([stdc++], [main], ,
+ [AC_MSG_ERROR([Stdc++ library not found])])
+
+AC_CHECK_LIB([cgicc], [main], ,
+ [AC_MSG_ERROR([Cgicc library not found])])
+
+#AC_CHECK_LIB([dl], [dlopen], ,
+# AC_MSG_ERROR([Dynamic loading library not found])
+
+AC_CHECK_LIB([fcgi], [FCGX_Init], [LIBS="-lfcgi++ -lfcgi $LIBS"],
+ [AC_MSG_ERROR([FastCGI libraries not found])])
+
+AC_CONFIG_FILES(Makefile echo/Makefile src/Makefile)
+AC_OUTPUT
diff --git a/echo/Makefile.am b/echo/Makefile.am
new file mode 100644
index 0000000..5cec782
--- /dev/null
+++ b/echo/Makefile.am
@@ -0,0 +1,5 @@
+INCLUDES = -I$(top_srcdir) -I$(top_builddir)
+
+lib_LIBRARIES = libecho.a
+libecho_a_SOURCES = config.cpp action.cpp
+pkginclude_HEADERS = config.h action.h
diff --git a/action/action.cpp b/echo/action.cpp
index 61ba329..899ce0c 100644
--- a/action/action.cpp
+++ b/echo/action.cpp
@@ -1,4 +1,5 @@
#include "action.h"
+
#include "config.h"
#include <dlfcn.h>
#include <stdexcept>
diff --git a/action/action.h b/echo/action.h
index 135f42e..fe030cd 100644
--- a/action/action.h
+++ b/echo/action.h
@@ -1,14 +1,12 @@
+#ifndef ACTION_H
+#define ACTION_H
+
#include <cgicc/Cgicc.h>
#include <iostream>
-#include <exception>
#include <string>
#include <vector>
#include <map>
-#ifndef _ACTION_H_
-#define _ACTION_H_
-
-
namespace action {
/**
@@ -104,4 +102,4 @@ public:
} /* end namespace */
-#endif
+#endif /* ACTION_H */
diff --git a/common/config.cpp b/echo/config.cpp
index 2566d89..2566d89 100644
--- a/common/config.cpp
+++ b/echo/config.cpp
diff --git a/common/config.h b/echo/config.h
index 9966a7e..31c0792 100644
--- a/common/config.h
+++ b/echo/config.h
@@ -1,11 +1,11 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
#include <string>
#include <vector>
#include <exception>
#include <confuse.h>
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
#define CONFIG_FILE "/etc/echo.conf"
using namespace std;
@@ -13,7 +13,7 @@ using namespace std;
/**
* Exception raised if a configuration parse error occured
*/
-class config_error: public exception
+class config_error : public exception
{
public:
virtual const char* what() {
@@ -49,4 +49,4 @@ public:
vector<string> modules() const;
};
-#endif
+#endif /* CONFIG_H */
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..fee1d43
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,4 @@
+INCLUDES = -I$(top_srcdir) -I$(top_builddir)
+
+bin_PROGRAMS = dispatcher.fcgi
+dispatcher_fcgi_SOURCES = dispatcher.cpp fcgi_io.cpp fcgi_io.h
diff --git a/fcgi/dispatcher.cpp b/src/dispatcher.cpp
index dd326d3..93b3af8 100644
--- a/fcgi/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -2,8 +2,8 @@
#include <fcgio.h>
#include <cgicc/Cgicc.h>
#include <cgicc/HTTPStatusHeader.h>
+#include <echo/action.h>
#include "fcgi_io.h"
-#include "action.h"
using namespace std;
using namespace cgicc;
diff --git a/fcgi/fcgi_io.cpp b/src/fcgi_io.cpp
index 15a2d09..ac3ccd4 100644
--- a/fcgi/fcgi_io.cpp
+++ b/src/fcgi_io.cpp
@@ -1,6 +1,7 @@
-#include <stdexcept>
#include "fcgi_io.h"
+#include <stdexcept>
+
fcgi_io::fcgi_io(FCGX_Request& request)
: std::ostream(&_out),
_request(request),
diff --git a/fcgi/fcgi_io.h b/src/fcgi_io.h
index 1eba173..574ba92 100644
--- a/fcgi/fcgi_io.h
+++ b/src/fcgi_io.h
@@ -1,12 +1,17 @@
+#ifndef FCGI_IO_H
+#define FCGI_IO_H
+
#include <map>
#include <string>
#include <iostream>
#include <fcgio.h>
#include <cgicc/CgiInput.h>
-#ifndef _FCGI_IO_H
-#define _FCGI_IO_H
-
+/**
+ * Class for performing input/output operations on an
+ * fcgi request. It also implements cgicc input class
+ * to bring fcgi compatability to cgicc.
+ */
class fcgi_io : public cgicc::CgiInput, public std::ostream
{
public:
@@ -29,4 +34,3 @@ protected:
};
#endif
-