fix previous commit, formatting
This commit is contained in:
@@ -314,7 +314,8 @@ void MainLoop::run() {
|
|||||||
if (scanCompleted > SCAN_REPEAT_COUNT) { // repeat failed scan only every Nth time
|
if (scanCompleted > SCAN_REPEAT_COUNT) { // repeat failed scan only every Nth time
|
||||||
scanCompleted = 0;
|
scanCompleted = 0;
|
||||||
scanRetry++;
|
scanRetry++;
|
||||||
logNotice(lf_main, "scan completed %d time(s), %s", scanRetry, scanRetry <= m_scanRetries ? "check again" : "end");
|
logNotice(lf_main, "scan completed %d time(s), %s", scanRetry,
|
||||||
|
scanRetry <= m_scanRetries ? "check again" : "end");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_scanStatus = SCAN_STATUS_RUNNING;
|
m_scanStatus = SCAN_STATUS_RUNNING;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src \
|
|||||||
noinst_LIBRARIES = libutils.a
|
noinst_LIBRARIES = libutils.a
|
||||||
|
|
||||||
libutils_a_SOURCES = \
|
libutils_a_SOURCES = \
|
||||||
|
arg.h arg.cpp \
|
||||||
log.h log.cpp \
|
log.h log.cpp \
|
||||||
tcpsocket.h tcpsocket.cpp \
|
tcpsocket.h tcpsocket.cpp \
|
||||||
thread.h thread.cpp \
|
thread.h thread.cpp \
|
||||||
|
|||||||
+11
-7
@@ -48,7 +48,8 @@ void calcCounts(const argDef *argDefs, int &count, int &shortCharsCount, int &sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildOpts(const argDef *argDefs, int &count, int &shortCharsCount, int &shortOptsCount, struct option *longOpts, char *shortChars, int *shortIndexes, char *shortOpts, int argDefIdx) {
|
void buildOpts(const argDef *argDefs, int &count, int &shortCharsCount, int &shortOptsCount,
|
||||||
|
struct option *longOpts, char *shortChars, int *shortIndexes, char *shortOpts, int argDefIdx) {
|
||||||
struct option *opt = longOpts+count;
|
struct option *opt = longOpts+count;
|
||||||
for (const argDef *arg = argDefs; arg && arg->help; arg++, argDefIdx++) {
|
for (const argDef *arg = argDefs; arg && arg->help; arg++, argDefIdx++) {
|
||||||
if (!arg->name) {
|
if (!arg->name) {
|
||||||
@@ -108,15 +109,19 @@ int argParse(const argParseOpt *parseOpt, int argc, char **argv, int *argIndex)
|
|||||||
shortOpts[shortOptsCount++] = '+'; // posix mode to stop at first non-option
|
shortOpts[shortOptsCount++] = '+'; // posix mode to stop at first non-option
|
||||||
shortOpts[shortOptsCount++] = ':'; // return ':' for missing option
|
shortOpts[shortOptsCount++] = ':'; // return ':' for missing option
|
||||||
if (!(parseOpt->flags & af_noHelp)) {
|
if (!(parseOpt->flags & af_noHelp)) {
|
||||||
buildOpts(helpArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0xff00);
|
buildOpts(helpArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0xff00);
|
||||||
}
|
}
|
||||||
if (!(parseOpt->flags & af_noVersion)) {
|
if (!(parseOpt->flags & af_noVersion)) {
|
||||||
buildOpts(versionArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0xff01);
|
buildOpts(versionArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0xff01);
|
||||||
}
|
}
|
||||||
buildOpts(parseOpt->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0);
|
buildOpts(parseOpt->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0);
|
||||||
int children = 0;
|
int children = 0;
|
||||||
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
||||||
buildOpts(child->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0x100*(++children));
|
buildOpts(child->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0x100*(++children));
|
||||||
}
|
}
|
||||||
optind = 1; // setting to 0 does not work
|
optind = 1; // setting to 0 does not work
|
||||||
int c = 0, longIdx = -1, ret = 0;
|
int c = 0, longIdx = -1, ret = 0;
|
||||||
@@ -320,8 +325,7 @@ void argHelp(const argParseOpt *parseOpt) {
|
|||||||
}
|
}
|
||||||
printf("Usage: %s [OPTION...] %s\n",
|
printf("Usage: %s [OPTION...] %s\n",
|
||||||
parseOpt->name,
|
parseOpt->name,
|
||||||
parseOpt->positional ? parseOpt->positional : ""
|
parseOpt->positional ? parseOpt->positional : "");
|
||||||
);
|
|
||||||
wrap(parseOpt->help, 0, 0);
|
wrap(parseOpt->help, 0, 0);
|
||||||
printArgs(parseOpt->argDefs, indent);
|
printArgs(parseOpt->argDefs, indent);
|
||||||
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
||||||
|
|||||||
+3
-3
@@ -16,8 +16,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIB_UTILS_ARGS_H_
|
#ifndef LIB_UTILS_ARG_H_
|
||||||
#define LIB_UTILS_ARGS_H_
|
#define LIB_UTILS_ARG_H_
|
||||||
|
|
||||||
namespace ebusd {
|
namespace ebusd {
|
||||||
|
|
||||||
@@ -94,4 +94,4 @@ void argHelp(const argParseOpt *parseOpt);
|
|||||||
|
|
||||||
} // namespace ebusd
|
} // namespace ebusd
|
||||||
|
|
||||||
#endif // LIB_UTILS_ARGS_H_
|
#endif // LIB_UTILS_ARG_H_
|
||||||
|
|||||||
@@ -1191,7 +1191,7 @@ int main(int argc, char* argv[]) {
|
|||||||
std::cerr << "incomplete IP arguments" << std::endl;
|
std::cerr << "incomplete IP arguments" << std::endl;
|
||||||
arg_index = argc; // force help output
|
arg_index = argc; // force help output
|
||||||
}
|
}
|
||||||
if (argc-arg_index < 1) {
|
if (arg_index < 0 || argc-arg_index < 1) {
|
||||||
if (flashFile) {
|
if (flashFile) {
|
||||||
printFileChecksum();
|
printFileChecksum();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|||||||
Reference in New Issue
Block a user