From 0e818d1a92ffc7199eaf9de57576f6dd17afb337 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 5 Apr 2009 13:11:44 +0000 Subject: [PATCH] added distrib infrastructure git-svn-id: svn://anubis/fart/trunk@220 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- Makefile | 4 +++- distrib/Makefile | 23 +++++++++++++++++++++++ distrib/distrib.cc | 23 +++++++++++++++++++++++ distrib/distrib.h | 17 +++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 distrib/Makefile create mode 100644 distrib/distrib.cc create mode 100644 distrib/distrib.h diff --git a/Makefile b/Makefile index fbf65fc..2258e80 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ +SHELL := bash + TARGET := fart ifdef WIN32 export CPPFLAGS += -I"$(shell cd)" @@ -9,7 +11,7 @@ export CXXFLAGS := -Wall -O2 LDFLAGS := -lfl -SUBDIRS := util shapes main parser +SUBDIRS := util shapes main parser distrib all: $(TARGET) diff --git a/distrib/Makefile b/distrib/Makefile new file mode 100644 index 0000000..a210eec --- /dev/null +++ b/distrib/Makefile @@ -0,0 +1,23 @@ + +OBJS := $(patsubst %.cc,%.o,$(wildcard *.cc)) +DEPS := $(OBJS:.o=.dep) + +all: $(DEPS) $(OBJS) + +%.o: %.cc + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< + +# Make dependency files +%.dep: %.cc + @set -e; rm -f $@; \ + $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +clean: + -$(RM) -f *.o *.dep + +# Include dependency files +ifndef CLEAN +-include $(DEPS) +endif diff --git a/distrib/distrib.cc b/distrib/distrib.cc new file mode 100644 index 0000000..0193534 --- /dev/null +++ b/distrib/distrib.cc @@ -0,0 +1,23 @@ + +#include "distrib.h" +#include +#include +using namespace std; + +int distrib::readHostFile(const char * filename) +{ + ifstream ifs(filename); + + if ( ! ifs.is_open() ) + return 1; + + string host; + while ( ! ifs.eof() ) + { + ifs >> host; + m_hosts.push_back(host); + } + + ifs.close(); + return 0; +} diff --git a/distrib/distrib.h b/distrib/distrib.h new file mode 100644 index 0000000..e019d55 --- /dev/null +++ b/distrib/distrib.h @@ -0,0 +1,17 @@ + +#ifndef DISTRIB_H +#define DISTRIB_H DISTRIB_H + +#include +#include + +class distrib +{ + public: + int readHostFile(const char * filename); + + protected: + std::vector m_hosts; +}; + +#endif