extern void main( void ) /**********************/ { MemInit(); UtilsInit(); Spawn( DoConvert ); FreeMemory(); MemFini(); }
int main( void ) /**********************/ { MemInit(); UtilsInit(); Spawn( DoConvert ); FreeMemory(); MemFini(); return( 0 ); }
static int bfddMain(int argc, char *argv[]) { int argIndex; SockAddr connectAddr; const char *valueString; //gLog.LogToFile("/tmp/bfd.log"); UtilsInit(); gLog.LogToSyslog("bfdd-control", false); gLog.Optional(Log::App, "Startup %x", getpid()); //Parse command line options for (argIndex = 1; argIndex < argc; argIndex++) { if (0 == strcmp("--altport", argv[argIndex])) { if (connectAddr.IsValid()) { fprintf(stderr, "Only a single --altport or --control option is allowed.\n"); exit(1); } // Backwards compatability only ... use --control connectAddr.FromString("127.0.0.1", ALT_PORTNUM); } else if (CheckArg("--control", argv[argIndex], &valueString)) { if (!valueString || *valueString == '\0') { fprintf(stderr, "--control must be followed by an '=' and a ip address with a port.\n"); exit(1); } if (!connectAddr.FromString(valueString)) { fprintf(stderr, "--control address <%s> is not an IPv4 or IPv6 address.\n", valueString); exit(1); } if (!connectAddr.HasPort()) { fprintf(stderr, "--control address must have a port specified. The address <%s> does not conatin a port.\n", valueString); exit(1); } } else if (0 == strncmp("--", argv[argIndex], 2)) { fprintf(stderr, "Unrecognized %s command line option %s.\n", ControlAppName, argv[argIndex]); exit(1); } else break; } if (argIndex >= argc) { fprintf(stderr, "No command. Try \"man %s\" for a list of commands.\n", ControlAppName); exit(1); } // "version" is special because we tell first. Than lest the beacon handle it. if (0 == strcmp(argv[argIndex], "version")) { fprintf(stdout, "%s v%s\n", ControlAppName, SofwareVesrion); } if (!connectAddr.IsValid()) connectAddr.FromString("127.0.0.1", PORTNUM); // "load" is special because we send a series of commands.. if (0 == strcmp(argv[argIndex], "load")) { argIndex++; if (argIndex >= argc) { fprintf(stderr, "Must supply a script file after 'load'\n"); exit(1); } fprintf(stdout, "Running script from file <%s>\n", argv[argIndex]); if (!doLoadScript(argv[argIndex], connectAddr)) { fprintf(stderr, "Script load failed.\n"); exit(1); } fprintf(stdout, "Completed script from file <%s>\n", argv[argIndex]); exit(0); } // To allow for quotes, we concatenate all the arguments, separating them with // "NULL". vector<char> buffer; buffer.reserve(MaxCommandSize); for (; argIndex < argc; argIndex++) { AddParamToBuffer(buffer, argv[argIndex]); } if (buffer.size() == 0) { fprintf(stderr, "No command. Try \"man %s\" for a list of commands.\n", ControlAppName); exit(1); } // argIndex is double null terminated. buffer.push_back('\0'); if (!SendData(&buffer.front(), buffer.size(), connectAddr)) exit(1); exit(0); }