71 #include <sys/ioctl.h>
82 #ifdef FIX8_HAVE_GETOPT_H
118 int main(
int argc,
char **argv)
122 #ifdef FIX8_HAVE_GETOPT_LONG
123 option long_options[]
125 {
"help", 0, 0,
'h' },
126 {
"offset", 1, 0,
'o' },
127 {
"version", 0, 0,
'v' },
128 {
"summary", 0, 0,
's' },
129 {
"context", 0, 0,
'c' },
133 while ((val = getopt_long (argc, argv,
GETARGLIST.c_str(), long_options, 0)) != -1)
135 while ((val = getopt (argc, argv,
GETARGLIST.c_str())) != -1)
142 cout <<
"Released under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3. See <http://fsf.org/> for details." << endl;
144 case ':':
case '?':
return 1;
146 case 'o': offset = stoi(optarg);
break;
147 case 's':
summary =
true;
break;
161 inputFile = argv[optind];
162 if (inputFile.empty())
168 bool usestdin(inputFile ==
"-");
169 filestdin ifs(usestdin ? &cin :
new ifstream(inputFile.c_str()), usestdin);
172 cerr <<
"Could not open " << inputFile << endl;
188 unique_ptr<Message> msg(Message::factory(
TEX::ctx(), buffer + offset));
191 MessageCount::iterator mitr(mc->find(msg->get_msgtype()));
192 if (mitr == mc->end())
193 mc->insert({msg->get_msgtype(), 1});
197 cout << *msg << endl;
203 cerr <<
"interrupted" << endl;
207 cerr <<
"exception: " << e.
what() << endl;
211 cerr <<
"exception: " << e.what() << endl;
214 cout << msgs <<
" messages decoded." << endl;
217 for (MessageCount::const_iterator mitr(mc->begin()); mitr != mc->end(); ++mitr)
220 cout << setw(20) << left << bme->
_name <<
" (\"" << mitr->first <<
"\")" <<
'\t' << mitr->second << endl;
231 um.
setdesc(
"f8print -- f8 protocol log printer");
232 um.
add(
'h',
"help",
"help, this screen");
233 um.
add(
'v',
"version",
"print version then exit");
234 um.
add(
'o',
"offset",
"bytes to skip on each line before parsing FIX message");
235 um.
add(
's',
"summary",
"summary, generate message summary");
236 um.
add(
'c',
"context",
"print the f8c generated beginstring and version. Use this to check which FIX version this build will work with.");
238 um.
add(
"@f8print myfix_server_protocol.log");
239 um.
add(
"@f8print f8print -s -o 12 myfix_client_protocol.log");
240 um.
add(
"@cat myfix_client_protocol.log | f8print -");
map< string, unsigned > MessageCount
Message instantiation table entry.
bool add(const char sw, const std::string &lsw, const std::string &help)
void sig_handler(int sig)
bool term_received(false)
const string GETARGLIST("hsvo:c")
const F8MetaCntx & ctx()
Compiler generated metadata object, accessed through this function.
void setdesc(const std::string &desc)
void print(std::ostream &os) const
#define FIX8_MAX_MSG_LENGTH
Abstract file or stdin input.
int main(int argc, char **argv)
const char * what() const
Convenient program help/usage wrapper. Generates a standardised usage message.