Commit 3d2aca51 authored by Axel Auweter's avatar Axel Auweter
Browse files

Wrote some rudimentary skeleton for the program.

parent eb89a2e6
//============================================================================
// Name : FileSpewer.cpp
// Author : Axel Auweter
// Version :
// Copyright : Leibniz Supercomputing Centre
// Description : Minimalistic tool to push file contents over MQTT
//============================================================================
#include <cstdio>
#include <cstdlib>
#include "Settings.h"
Settings* mySettings;
void usage() {
printf("Usage: FileSpewer [-i <interval>] [-h <host>] <filename>\n\n");
printf("FileSpewer will send the contents of <filename> every <interval> milliseconds\n");
printf("to the broker <host>. The default value for <interval> is 1000 milliseconds and\n");
printf("the default <host> is localhost.\n");
}
int main(int argc, const char* argv[]) {
/* Check command line */
mySettings = new Settings(argc, argv);
switch(mySettings->getMode()) {
case USAGE:
usage();
break;
default:
break;
}
/* Clean up */
delete mySettings;
return EXIT_SUCCESS;
}
CXXFLAGS = -O2 -g -Wall -Werr -fmessage-length=0
OBJS = FileSpewer.o Settings.o
LIBS =
TARGET = FileSpewer
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
/*
* Settings.cpp
*
* Created on: Jan 11, 2013
* Author: Axel Auweter
*/
#include <cstdio>
#include "Settings.h"
Settings::Settings(int argc, const char* argv[]) : argc_(argc), argv_(argv)
{
/* Parse command line */
if (argc <= 1) {
mode_ = USAGE;
}
}
UsageMode Settings::getMode()
{
return mode_;
}
/*
* Settings.h
*
* Created on: Jan 11, 2013
* Author: Axel Auweter
*/
#ifndef SETTINGS_H_
#define SETTINGS_H_
typedef enum {USAGE, ABORT, SPEW} UsageMode;
class Settings {
protected:
int argc_;
const char** argv_;
UsageMode mode_;
public:
Settings(int argc, const char* argv[]);
UsageMode getMode();
};
#endif /* SETTINGS_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment