int __parseArgs(PyObject *args, const char *types, ...) { int count = PyObject_Size(args); va_list list; va_start(list, types); #ifdef PYPY_VERSION return _parseArgs(args, count, types, list); #else return _parseArgs(((PyTupleObject *)(args))->ob_item, count, types, list); #endif }
/** \brief Application class constructor. * Create the initial window and place it in the center * of the screen. * * \param argc The number of arguments passed to the program. * \param argv The array of char * strings that were passed to the program. */ App::App(int argc, char **argv) : os::Application( "application/x-vnd.syllable-net-Transferrer" ) { m_pcMainWindow = new MainWindow(); // Show the window if the command line arguments were correct. if ( _parseArgs((MainWindow *)m_pcMainWindow, argc, argv) ) { m_pcMainWindow->Show(); m_pcMainWindow->MakeFocus(); } }
/** * Parses first the configuration file, and then overrides with any * command-line options that were specified. */ int Config::parse(int argc, char **argv) { int error; // read the config file error = _load(); if(error) { return error; } // parse the arguments return _parseArgs(argc, argv); }
int __parseArg(PyObject *arg, const char *types, ...) { va_list list; va_start(list, types); #ifdef PYPY_VERSION { struct arg_tuple { PyObject *tuple; arg_tuple(PyObject *arg) { tuple = PyTuple_Pack(1, arg); } ~arg_tuple() { Py_DECREF(tuple); } } tuple_arg(arg); return _parseArgs(tuple_arg.tuple, 1, types, list); } #else return _parseArgs(&arg, 1, types, list); #endif }
bool metisConfigurationFile_Process(MetisConfigurationFile *configFile) { assertNotNull(configFile, "Parameter configFile must be non-null"); // default to a "true" return value and only set to false if we encounter an error. bool success = true; #define BUFFERLEN 2048 char buffer[BUFFERLEN]; configFile->linesRead = 0; // always clear errors and fseek to start of file in case we get called multiple times. clearerr(configFile->fh); rewind(configFile->fh); while (success && fgets(buffer, BUFFERLEN, configFile->fh) != NULL) { configFile->linesRead++; char *stripedBuffer = _trim(buffer); if (strlen(stripedBuffer) > 0) { if (stripedBuffer[0] != '#') { // not empty and not a comment // _parseArgs will modify the string char *copy = parcMemory_StringDuplicate(stripedBuffer, strlen(stripedBuffer)); PARCList *args = _parseArgs(copy); MetisCommandReturn result = metisControlState_DispatchCommand(configFile->controlState, args); // we ignore EXIT from the configuration file if (result == MetisCommandReturn_Failure) { if (metisLogger_IsLoggable(metisForwarder_GetLogger(configFile->metis), MetisLoggerFacility_Config, PARCLogLevel_Error)) { metisLogger_Log(metisForwarder_GetLogger(configFile->metis), MetisLoggerFacility_Config, PARCLogLevel_Error, __func__, "Error on input file %s line %d: %s", configFile->filename, configFile->linesRead, stripedBuffer); } success = false; } parcList_Release(&args); parcMemory_Deallocate((void **) ©); } } } if (ferror(configFile->fh)) { if (metisLogger_IsLoggable(metisForwarder_GetLogger(configFile->metis), MetisLoggerFacility_Config, PARCLogLevel_Error)) { metisLogger_Log(metisForwarder_GetLogger(configFile->metis), MetisLoggerFacility_Config, PARCLogLevel_Error, __func__, "Error on input file %s line %d: (%d) %s", configFile->filename, configFile->linesRead, errno, strerror(errno)); } success = false; } return success; }