int main (int argc, const char **argv) { gSymbolList = (const char**)calloc (MAX_SUBSCRIPTIONS, sizeof (char*)); /* Enabling Normal MAMA Logging, to provide feedback to users regarding * processing. */ mama_enableLogging (stderr, MAMA_LOG_LEVEL_NORMAL); parseCommandLine (argc, argv); mama_log (MAMA_LOG_LEVEL_NORMAL, "Reading symbols from file, please standby."); initializeMama (); prepareDictionaryListener(); readSymbolsFromFile(); createPublisher (); start_timed_publish(); mama_log (MAMA_LOG_LEVEL_NORMAL, "Ready for Subscriptions."); mama_start (gPubBridge); return 0; }
void MamaLogFile::enableLogging (const char* file, MamaLogLevel level) { if (file && (strlen(file) > 0)) { mamaTry (mama_logToFile (file, level)); } else { mamaTry (mama_enableLogging (NULL, level)); } }
static void parseCommandLine (int argc, const char** argv) { int i = 0; for (i = 1; i < argc;) { if (strcmp (argv[i], "-S") == 0) { gPubSource = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-f") == 0) { gFilename = argv[i + 1]; i += 2; } else if ((strcmp (argv[i], "-h") == 0) || (strcmp (argv[i], "-?") == 0)) { usage (0); i++; } else if (strcmp ("-tport", argv[i]) == 0) { gPubTransportName = argv[i+1]; i += 2; } else if (strcmp ("-m", argv[i]) == 0) { gPubMiddleware = argv[i+1]; i += 2; } else if (strcmp ("-q", argv[i]) == 0) { gQuietness++; i++; } else if (strcmp (argv[i], "-i") == 0) { gTimeInterval = strtod (argv[i+1], NULL); i += 2; } else if (strcmp (argv[i], "-dictionary") == 0) { gDictionaryFile = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-r") == 0 || strcmp (argv[i], "-rewind") == 0) { gRewind = 1; i++; } else if (strcmp (argv[i], "-v") == 0) { if (gSubscLogLevel == MAMA_LOG_LEVEL_WARN) { gSubscLogLevel = MAMA_LOG_LEVEL_NORMAL; mama_enableLogging (stderr, MAMA_LOG_LEVEL_NORMAL); } else if (gSubscLogLevel == MAMA_LOG_LEVEL_NORMAL) { gSubscLogLevel = MAMA_LOG_LEVEL_FINE; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINE); } else if (gSubscLogLevel == MAMA_LOG_LEVEL_FINE) { gSubscLogLevel = MAMA_LOG_LEVEL_FINER; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINER); } else { gSubscLogLevel = MAMA_LOG_LEVEL_FINEST; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINEST); } i++; } else { printf ("Unknown arg %s\n", argv[i]); usage (0); } } /* * Dictionary is a required option. If not passed display a warning and * drop out. */ if (NULL == gDictionaryFile) { printf ("\nWARNING: A dictionary file must be specified. Please pass a " "valid dictionary via the -dictionary command line option.\n\n"); usage(1); } }
static void parseCommandLine (int argc, const char** argv) { int i = 0; for (i = 1; i < argc;) { if (strcmp (argv[i], "-SS") == 0) { gSubSource = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-SP") == 0) { gPubSource = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-s") == 0) { gSymbolList[gNumSymbols++]=strdup (argv[i + 1]); i += 2; } else if (strcmp (argv[i], "-f") == 0) { gFilename = argv[i + 1]; i += 2; } else if ((strcmp (argv[i], "-h") == 0) || (strcmp (argv[i], "-?") == 0)) { usage (0); i++; } else if (strcmp ("-tports", argv[i]) == 0) { gSubTransportName = argv[i+1]; i += 2; } else if (strcmp ("-tportp", argv[i]) == 0) { gPubTransportName = argv[i+1]; i += 2; } else if (strcmp ("-ms", argv[i]) == 0) { gSubMiddleware = argv[i+1]; i += 2; } else if (strcmp ("-mp", argv[i]) == 0) { gPubMiddleware = argv[i+1]; i += 2; } else if (strcmp ("-q", argv[i]) == 0) { gQuietness++; i++; } else if (strcmp ("-sync", argv[i]) == 0) { gSendSync=1; i++; } else if (strcmp( argv[i], "-v") == 0 ) { if (gSubscLogLevel == MAMA_LOG_LEVEL_WARN) { gSubscLogLevel = MAMA_LOG_LEVEL_NORMAL; mama_enableLogging (stderr, MAMA_LOG_LEVEL_NORMAL); } else if (gSubscLogLevel == MAMA_LOG_LEVEL_NORMAL) { gSubscLogLevel = MAMA_LOG_LEVEL_FINE; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINE); } else if (gSubscLogLevel == MAMA_LOG_LEVEL_FINE) { gSubscLogLevel = MAMA_LOG_LEVEL_FINER; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINER); } else { gSubscLogLevel = MAMA_LOG_LEVEL_FINEST; mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINEST); } i++; } else { printf ("Unknown arg %s\n", argv[i]); usage (0); } } if (gNumSymbols==0) readSymbolsFromFile (); }
void parseCommandLine (int argc, const char** argv) { int i = 0; for (i = 1; i < argc;) { if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-?") == 0)) { usage(0); } else if(strcmp("-tport", argv[i]) == 0) { gTransportName = argv[i+1]; i += 2; } else if ((strcmp (argv[i], "-g") == 0) || (strcmp (argv[i], "-group") == 0)) { gFtGroup = argv[i+1]; i += 2; } else if ((strcmp (argv[i], "-w") == 0) || (strcmp (argv[i], "-weight") == 0)) { gFtWeight = strtoul (argv[i+1], NULL, 10); i += 2; } else if (strcmp( argv[i], "-v") == 0) { if (mama_getLogLevel() == MAMA_LOG_LEVEL_WARN) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_NORMAL); } else if (mama_getLogLevel() == MAMA_LOG_LEVEL_NORMAL) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINE); } else if( mama_getLogLevel() == MAMA_LOG_LEVEL_FINE) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINER); } else { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINEST); } i++; } else if (strcmp ("-m", argv[i]) == 0) { gMiddleware = (argv[i+1]); i += 2; } else if (strcmp (argv[i], "-b") == 0) { gFtType = MAMA_FT_TYPE_BRIDGE; ++i; } else { i++; } } }
void parseCommandLine (int argc, const char** argv) { int i = 0; for (i = 1; i < argc;) { if (strcmp ("-s", argv[i]) == 0) { gTopic = argv[i+1]; i += 2; } else if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-?") == 0)) { usage(0); } else if(strcmp("-tport", argv[i]) == 0) { gTransportName = argv[i+1]; i += 2; } else if (strcmp ("-q", argv[i]) == 0) { gQuietLevel++; i++; } else if (strcmp( argv[i], "-v") == 0) { if (mama_getLogLevel() == MAMA_LOG_LEVEL_WARN) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_NORMAL); } else if (mama_getLogLevel() == MAMA_LOG_LEVEL_NORMAL) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINE); } else if( mama_getLogLevel() == MAMA_LOG_LEVEL_FINE) { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINER); } else { mama_enableLogging(stderr, MAMA_LOG_LEVEL_FINEST); } i++; } else if (strcmp ("-m", argv[i]) == 0) { gMiddleware = (argv[i+1]); i += 2; } else if (strcmp ("-w", argv[i]) == 0) { if (gTport) { printf ("A subscription can only be wildcard or " "tport not both\n"); exit(1); } gWildcard = 1; i += 1; } else if (strcmp ("-mute", argv[i]) == 0) { gMuteTopic = argv[i+1]; i += 2; } else if (strcmp ("-t", argv[i]) == 0) { if (gWildcard) { printf ("A subscription can only be wildcard or " "tport not both\n"); exit(1); } gTport = 1; i += 1; } else if (strcmp(argv[i], "-V") == 0) { if (gSubscLogLevel == MAMA_LOG_LEVEL_NORMAL) { gSubscLogLevel = MAMA_LOG_LEVEL_FINE; } else if (gSubscLogLevel == MAMA_LOG_LEVEL_FINE) { gSubscLogLevel = MAMA_LOG_LEVEL_FINER; } else { gSubscLogLevel = MAMA_LOG_LEVEL_FINEST; } i++; } else { i++; } } if (gQuietLevel < 2) { printf ("Starting Subscriber with:\n topic: %s\n" " transport: %s\n", gTopic, gTransportName); } }
void Mama::enableLogging (MamaLogLevel level, FILE *logFile) { mamaTry (mama_enableLogging (logFile, level)); }
/********************************************************** * mc_parseCommandLine * **********************************************************/ void mc_parseCommandLine ( int argc, const char ** argv, const char ** topic, const char ** transportName, const char ** middleware, uint32_t * pSampleRate, uint32_t * pIntervalRate, MamaLogLevel *pMamaLogLevel ) { int i = 0; for (i = 1; i < argc;) { if (strcmp (argv[i], "-s") == 0) { if (argv[i + 1] != NULL) { gSymbolList[gNumSymbols++]=strdup (argv[i + 1]); i += 2; } else { gSymbolList[gNumSymbols++]=""; i += 2; } } else if (strcmp ("-flush", argv[i]) == 0) { gflush=1; i++; } else if (strcmp ("-t", argv[i]) == 0) { gTimeInterval = (uint32_t)atoi(argv[i+1]); i += 2; } else if (strcmp ("-i", argv[i]) == 0) { *pIntervalRate = (uint32_t)atoi(argv[i+1]); if (*pIntervalRate < MC_MIN_INTERVAL_RATE) { printf("Warning - interval rate must be a minimum of %d messages\n", MC_MIN_SAMPLE_RATE); *pIntervalRate = MC_MIN_INTERVAL_RATE; printf("Modified interval rate to %d\n", MC_MIN_INTERVAL_RATE); } i += 2; } else if (strcmp ("-r", argv[i]) == 0) { *pSampleRate = (uint32_t)atoi(argv[i+1]); if (*pSampleRate < MC_MIN_SAMPLE_RATE) { printf("Warning - sample rate must be a minimum of %d\n", MC_MIN_SAMPLE_RATE); *pSampleRate = MC_MIN_SAMPLE_RATE; printf("Modified sample rate to %d\n", MC_MIN_SAMPLE_RATE); } i += 2; } else if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0) || (strcmp(argv[i], "-?") == 0)) { mc_usage(0); } else if (strcmp (argv[i], "-f") == 0) { gSymFileName = argv[i + 1]; i += 2; } else if(strcmp("-tport", argv[i]) == 0) { *transportName = argv[i+1]; i += 2; } else if (strcmp ("-m", argv[i]) == 0) { *middleware = (argv[i+1]); i += 2; } else if (strcmp(argv[i], "-S") == 0) { gSymbolNamespace = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-v") == 0) { if ( mama_getLogLevel () == MAMA_LOG_LEVEL_WARN ) { mama_enableLogging( stderr, MAMA_LOG_LEVEL_NORMAL ); } else if ( mama_getLogLevel () == MAMA_LOG_LEVEL_NORMAL ) { mama_enableLogging( stderr, MAMA_LOG_LEVEL_FINE ); } else if( mama_getLogLevel () == MAMA_LOG_LEVEL_FINE ) { mama_enableLogging( stderr, MAMA_LOG_LEVEL_FINER ); } else { mama_enableLogging( stderr, MAMA_LOG_LEVEL_FINEST ); } i++; } } printf ("Starting consumer with:\n topic: %s\n" " transport: %s\n", *topic, *transportName); }
static mama_status parseCommandLine (mamaCaptureConfig subCapture, mamaCaptureList* captureList, int argc, const char** argv) { mamaCapture * capture = (mamaCapture*)subCapture; mamaCaptureSourceList* sourceList = NULL; int i; if (capture == NULL) return MAMA_STATUS_NULL_ARG; for (i = 1; i < argc; ) { if (strcmp (argv[i], "-MS") == 0) { if (gCounter == 0) { mamaCaptureList_allocate (&sourceList); } *captureList = (mamaCaptureList)sourceList; gSource = (char*)argv[i + 1]; i+=2; } else if (strcmp (argv[i], "-I") == 0) { capture->myRequireInitial = 0; i++; } else if (strcmp (argv[i], "-d") == 0) { capture->myDumpDataDict = 1; i++; } else if (strcmp (argv[i], "-subs")==0) { capture->myDumpList = 1; i++; } else if (strcmp (argv[i], "-m")==0) { capture->myMiddleware = argv[i+1]; i+=2; } else if (strcmp (argv[i], "-DF") == 0) { capture->myDictToFile = 1; capture->myDictFile = argv[i+1]; i+=2; } else if (strcmp (argv[i], "-B") == 0) { capture->myBuildDataDict = 0; i++; } else if (strcmp (argv[i], "-outfile") == 0) { capture->myCaptureFilename = argv[i + 1]; i += 2; } else if (strcmp (argv[i], "-r") == 0) { capture->myThrottle = strtol (argv[i+1], NULL, 10); i += 2; } else if (strcmp (argv[i], "-t") == 0) { capture->myTimeout = strtod (argv[i+1], NULL); i += 2; } else if (strcmp (argv[i], "-dict_tport") == 0) { capture->myDictTport = argv[i+1]; i += 2; } else if (strcmp (argv[i], "-d") == 0) { capture->myDictSourceName = argv[i + 1]; i += 2; } else if ((strcmp (argv[i], "-help") == 0) || (strcmp (argv[i], "-?") == 0)) { usage (0); i++; } else if (strcmp (argv[i], "-v") == 0) { if (mama_getLogLevel() == MAMA_LOG_LEVEL_WARN) { mama_enableLogging (stderr, MAMA_LOG_LEVEL_NORMAL); } else if (mama_getLogLevel() == MAMA_LOG_LEVEL_NORMAL) { mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINE); } else if (mama_getLogLevel() == MAMA_LOG_LEVEL_FINE) { mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINER); } else { mama_enableLogging (stderr, MAMA_LOG_LEVEL_FINEST); } i++; } else if (strcmp( argv[i], "-V" ) == 0) { if (capture->mySubscLogLevel == MAMA_LOG_LEVEL_NORMAL) { capture->mySubscLogLevel = MAMA_LOG_LEVEL_FINE; } else if (capture->mySubscLogLevel == MAMA_LOG_LEVEL_FINE) { capture->mySubscLogLevel = MAMA_LOG_LEVEL_FINER; } else { capture->mySubscLogLevel = MAMA_LOG_LEVEL_FINEST; } i++; } else { i++; } } /*If argv params are not specified display usage and exit*/ if ( *captureList == NULL) { usage (0); } return MAMA_STATUS_OK; }