65 #ifdef FIX8_HAVE_GETOPT_H
84 int main(
int argc,
char **argv)
86 bool dump(
false), rawdump(
false), indexonly(
false),
quiet(
false);
90 #ifdef FIX8_HAVE_GETOPT_LONG
91 const option long_options[]
93 {
"help", 0, 0,
'h' },
94 {
"dump", 0, 0,
'd' },
95 {
"version", 0, 0,
'v' },
96 {
"rawdump", 0, 0,
'D' },
97 {
"index", 0, 0,
'i' },
98 {
"quiet", 0, 0,
'q' },
99 {
"send", 1, 0,
'S' },
100 {
"receive", 1, 0,
'R' },
104 while ((val = getopt_long (argc, argv,
GETARGLIST.c_str(), long_options, 0)) != -1)
106 while ((val = getopt (argc, argv,
GETARGLIST.c_str())) != -1)
113 cout <<
"Released under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3. See <http://fsf.org/> for details." << endl;
116 case 'D': rawdump =
true;
117 case 'd': dump =
true;
break;
118 case 'i': indexonly =
true;
break;
119 case 'q': quiet =
true;
break;
120 case 'S':
next_send = stoul(optarg);
break;
121 case 'R': next_receive = stoul(optarg);
break;
122 case ':':
case '?':
return 1;
129 cerr <<
"no input persistence file prefix specified" << endl;
133 const string dbFname(argv[optind]);
134 const string dbIname(dbFname +
".idx");
138 fdset() : fod(), iod() {}
139 ~fdset() { close(iod); close(fod); }
143 if ((fds.fod = open(dbFname.c_str(), O_RDONLY |
O_BINARY)) < 0)
145 cerr <<
"Error opening existing database: " << dbFname <<
" (" << strerror(errno) <<
')' << endl;
148 if ((fds.iod = open(dbIname.c_str(), O_RDWR |
O_BINARY)) < 0)
150 cerr <<
"Error opening existing database index: " << dbIname <<
" (" << strerror(errno) <<
')' << endl;
155 ssize_t blrd(read(fds.iod, static_cast<void *>(&iprec),
sizeof(
IPrec)));
158 cerr <<
"Error reading existing database index: " << dbIname <<
" (" << strerror(errno) <<
')' << endl;
162 if (!rawdump && !quiet)
165 cout <<
"Next send receive" << endl;
166 cout <<
"==============================" << endl;
167 cout <<
"Current " << left << setw(10) << iprec.
_prec.
_offset << right << setw(10) << iprec.
_prec.
_size << endl;
178 if (lseek(fds.iod, 0, SEEK_SET) < 0)
181 cerr <<
"Error could not seek to 0 for seqnum persitence: " << dbIname << endl;
184 if (write (fds.iod, static_cast<void *>(&iprec),
sizeof(iprec)) !=
sizeof(iprec))
187 cerr <<
"Error writing seqnum persitence: " << dbIname << endl;
192 cout <<
"New " << left << setw(10) << iprec.
_prec.
_offset << right << setw(10) << iprec.
_prec.
_size << endl;
198 blrd = read(fds.iod, static_cast<void *>(&iprec),
sizeof(
IPrec));
201 cerr <<
"Error reading existing database index: " << dbIname <<
" (" << strerror(errno) <<
')' << endl;
208 cout << iprec << endl;
217 cerr <<
"Error could not seek to correct index location " << iprec.
_prec.
_offset <<
" for get: " << dbFname << endl;
224 cerr <<
"Error could not read message record for seqnum " << iprec.
_seq <<
" from: " << dbFname
225 <<
": trying to read " << iprec.
_prec.
_size <<
", but available " << bytes_read
233 cout << buff << endl;
243 um.
setdesc(
"seqedit -- edit next expected send/receive for file based persister. Note: fix8pro users should use f8pseqedit which works with any persister");
244 um.
add(
'R',
"receive",
"set next expected receive sequence number");
245 um.
add(
'S',
"send",
"set next send sequence number");
246 um.
add(
'd',
"dump",
"dump all the records in both the index and the data file");
247 um.
add(
'D',
"rawdump",
"dump all the raw data records referenced in the index");
248 um.
add(
'h',
"help",
"help, this screen");
249 um.
add(
'i',
"index",
"only dump the index not the data records");
250 um.
add(
'q',
"quiet",
"set the sequence numbers silently");
251 um.
add(
'v',
"version",
"print version, exit");
253 um.
add(
"@seqedit client.DLD_TEX.TEX_DLD");
254 um.
add(
"@seqedit -R 23417 -S 2341 client.DLD_TEX.TEX_DLD");
255 um.
add(
"@seqedit -d client.DLD_TEX.TEX_DLD");
256 um.
add(
"@seqedit -D client.DLD_TEX.TEX_DLD");
257 um.
add(
"@seqedit -id client.DLD_TEX.TEX_DLD");
258 um.
add(
"@seqedit -S 2005 server.TEX_DLD.DLD_TEX");
bool add(const char sw, const std::string &lsw, const std::string &help)
void setdesc(const std::string &desc)
const string GETARGLIST("hvdDR:S:iq")
void print(std::ostream &os) const
#define FIX8_MAX_MSG_LENGTH
int main(int argc, char **argv)
Convenient program help/usage wrapper. Generates a standardised usage message.