Example #1
1
/**
 * \brief Start parsing.
 * \param LogProc A Pointer to the logging procedure.
 */
void CAuxParser::Parse(PFNLOGPROC LogProc)
{
	m_LogProc = LogProc;
	m_Errors = 0;
	m_BibData.Empty();
	m_BibStyle.Empty();
	CString str;
	if (!m_AuxFile.IsEmpty()) {
		CFile f;
		CFileException ex;
		if (f.Open(m_AuxFile, CFile::modeRead | CFile::shareDenyWrite, &ex)) {
			str.Format(AfxLoadString(IDS_STRING_PARSING), m_AuxFile);
			AddLog(str);
			CBibReader reader(&f);
			ParseFile(&reader);
			f.Close();
		} else {
			m_Errors++;
			TCHAR msg[MAX_PATH];
			ex.GetErrorMessage(msg, MAX_PATH);
			str.Format(AfxLoadString(IDS_STRING_ERROR), msg);
			AddLog(str);
		}
	}
}
Example #2
0
void ParseStack::DoInclude(ConfigTag* tag, int flags)
{
	if (flags & FLAG_NO_INC)
		throw CoreException("Invalid <include> tag in file included with noinclude=\"yes\"");

	std::string mandatorytag;
	tag->readString("mandatorytag", mandatorytag);

	std::string name;
	if (tag->readString("file", name))
	{
		if (tag->getBool("noinclude", false))
			flags |= FLAG_NO_INC;
		if (tag->getBool("noexec", false))
			flags |= FLAG_NO_EXEC;
		if (!ParseFile(ServerInstance->Config->Paths.PrependConfig(name), flags, mandatorytag))
			throw CoreException("Included");
	}
	else if (tag->readString("executable", name))
	{
		if (flags & FLAG_NO_EXEC)
			throw CoreException("Invalid <include:executable> tag in file included with noexec=\"yes\"");
		if (tag->getBool("noinclude", false))
			flags |= FLAG_NO_INC;
		if (tag->getBool("noexec", true))
			flags |= FLAG_NO_EXEC;
		if (!ParseFile(name, flags, mandatorytag, true))
			throw CoreException("Included");
	}
}
Example #3
0
JBoolean
CBFileNode::ParseFiles
	(
	CBFileListTable*			parser,
	const JPtrArray<JString>&	allSuffixList,
	CBSymbolList*				symbolList,
	CBCTree*					cTree,
	CBJavaTree*					javaTree,
	CBPHPTree*					phpTree,
	JProgressDisplay&			pg
	)
	const
{
	JString fullName, trueName;
	if (GetFullName(&fullName) && JGetTrueName(fullName, &trueName))
		{
		if (!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}

		const CBTextFileType type = (CBGetPrefsManager())->GetFileType(trueName);
		if ((CBGetDocumentManager())->GetComplementFile(trueName, type, &fullName,
														GetProjectDoc(), kJFalse) &&
			JGetTrueName(fullName, &trueName) &&
			!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}
		}
	return CBFileNodeBase::ParseFiles(parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg);
}
Example #4
0
// main program
int main(int argc, char *argv[]) {
    Options options;
    vector<string> filenames;
    // Process command-line arguments
    for (int i = 1; i < argc; ++i) {
        if (!strcmp(argv[i], "--ncores")) options.nCores = atoi(argv[++i]);
        else if (!strcmp(argv[i], "--outfile")) options.imageFile = argv[++i];
        else if (!strcmp(argv[i], "--quick")) options.quickRender = true;
        else if (!strcmp(argv[i], "--topng")){ options.topng = true;
        options.pngFile = argv[++i];
        }
        else if (!strcmp(argv[i], "--background")){ options.withBackground = true;
        options.backgroundImage = argv[++i];
        //This is neccesary to prevent exceptions caused by Magick++
        //@TODO: Mail the Magick++ list about this.
        options.nCores = 1;
        }
        else if (!strcmp(argv[i], "--quiet")) options.quiet = false;
        else if (!strcmp(argv[i], "--verbose")) options.verbose = true;
        else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
            printf("usage: pbrt [--ncores n] [--outfile filename] [--quick] [--quiet] "
                   "[--verbose] [--topng png_filename] [--help] <filename.pbrt> ...\n");
            return 0;
        }
        else filenames.push_back(argv[i]);
    }

    // Print welcome banner
    // Disabled, enable later.
    if (!options.quiet) {
        printf("pbrt version %s of %s at %s [Detected %d core(s)]\n",
               PBRT_VERSION, __DATE__, __TIME__, NumSystemCores());
        printf("Relativistic Rendering, Alex, Allwin, Sanchit\n");
        /*
        printf("Copyright (c)1998-2010 Matt Pharr and Greg Humphreys.\n");
        printf("The source code to pbrt (but *not* the book contents) is covered by the GNU GPL.\n");
        printf("See the file COPYING.txt for the conditions of the license.\n");
        */
        fflush(stdout);

    }
    pbrtInit(options);

    //extern Background bground;
    // Process scene description
    PBRT_STARTED_PARSING();
    if (filenames.size() == 0) {
        // Parse scene from standard input
        ParseFile("-");
    } else {
        // Parse scene from input files
        for (u_int i = 0; i < filenames.size(); i++)
            if (!ParseFile(filenames[i]))
                Error("Couldn't open scene file \"%s\"", filenames[i].c_str());
    }
    pbrtCleanup();
    return 0;
}
Example #5
0
File: parse.c Project: Nehamkin/jwm
/** Parse the JWM configuration. */
void ParseConfig(const char *fileName)
{
   if(!ParseFile(fileName, 0)) {
      if(JUNLIKELY(!ParseFile(SYSTEM_CONFIG, 0))) {
         ParseError(NULL, "could not open %s or %s", fileName, SYSTEM_CONFIG);
      }
   }
   ValidateTrayButtons();
   ValidateKeys();
}
Example #6
0
// main program
int main(int argc, char *argv[]) {
    Options options;
    vector<string> filenames;

    /************* TWEAKS *************/

    if(chdir("source_files/pbrt"));

    argc = 4;
    argv[1] = "--ncores";
    argv[2] = "1";
    argv[3] = "cornell-ML.pbrt";
    /***********************************/

    // Process command-line arguments
    for (int i = 1; i < argc; ++i) {
        if (!strcmp(argv[i], "--ncores")) options.nCores = atoi(argv[++i]);
        else if (!strcmp(argv[i], "--outfile")) options.imageFile = argv[++i];
        else if (!strcmp(argv[i], "--quick")) options.quickRender = true;
        else if (!strcmp(argv[i], "--quiet")) options.quiet = true;
        else if (!strcmp(argv[i], "--verbose")) options.verbose = true;
        else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
            printf("usage: pbrt [--ncores n] [--outfile filename] [--quick] [--quiet] "
                   "[--verbose] [--help] <filename.pbrt> ...\n");
            return 0;
        }
        else filenames.push_back(argv[i]);
    }

    // Print welcome banner
    if (!options.quiet) {
        printf("pbrt version %s of %s at %s [Detected %d core(s)]\n",
               PBRT_VERSION, __DATE__, __TIME__, NumSystemCores());
        printf("Copyright (c)1998-2014 Matt Pharr and Greg Humphreys.\n");
        printf("The source code to pbrt (but *not* the book contents) is covered by the BSD License.\n");
        printf("See the file LICENSE.txt for the conditions of the license.\n");
        fflush(stdout);
    }
    pbrtInit(options);
    // Process scene description
    PBRT_STARTED_PARSING();
    if (filenames.size() == 0) {
        // Parse scene from standard input
        ParseFile("-");
    } else {
        // Parse scene from input files
        for (u_int i = 0; i < filenames.size(); i++)
            if (!ParseFile(filenames[i]))
                Error("Couldn't open scene file \"%s\"", filenames[i].c_str());
    }
    pbrtCleanup();
    return 0;
}
bool pawsNpcDialogWindow::LoadSetting()
{
    csRef<iDocument> doc;
    csRef<iDocumentNode> root,npcDialogNode, npcDialogOptionsNode;
    csString option;

    doc = ParseFile(psengine->GetObjectRegistry(), CONFIG_NPCDIALOG_FILE_NAME);
    if(doc == NULL)
    {
        //load the default configuration file in case the user one fails (missing or damaged)
        doc = ParseFile(psengine->GetObjectRegistry(), CONFIG_NPCDIALOG_FILE_NAME_DEF);
        if(doc == NULL)
        {
            Error2("Failed to parse file %s", CONFIG_NPCDIALOG_FILE_NAME_DEF);
            return false;
        }
    }

    root = doc->GetRoot();
    if(root == NULL)
    {
        Error1("npcdialog_def.xml or npcdialog.xml has no XML root");
        return false;
    }

    npcDialogNode = root->GetNode("npcdialog");
    if(npcDialogNode == NULL)
    {
        Error1("npcdialog_def.xml or npcdialog.xml has no <npcdialog> tag");
        return false;
    }

    // Load options for the npc dialog
    npcDialogOptionsNode = npcDialogNode->GetNode("npcdialogoptions");
    if(npcDialogOptionsNode != NULL)
    {
        csRef<iDocumentNodeIterator> oNodes = npcDialogOptionsNode->GetNodes();
        while(oNodes->HasNext())
        {
            csRef<iDocumentNode> option = oNodes->Next();
            csString nodeName(option->GetValue());

            if(nodeName == "usenpcdialog")
            {
                //showWindow->SetState(!option->GetAttributeValueAsBool("value"));
                useBubbles = option->GetAttributeValueAsBool("value");
            }
        }
    }

    return true;
}
Example #8
0
// main program
int main(int argc, char *argv[]) {
    Options options;
    std::vector<std::string> filenames;
    // Process command-line arguments
    for (int i = 1; i < argc; ++i) {
        if (!strcmp(argv[i], "--ncores") || !strcmp(argv[i], "--nthreads"))
            options.nThreads = atoi(argv[++i]);
        else if (!strcmp(argv[i], "--outfile"))
            options.imageFile = argv[++i];
        else if (!strcmp(argv[i], "--quick"))
            options.quickRender = true;
        else if (!strcmp(argv[i], "--quiet"))
            options.quiet = true;
        else if (!strcmp(argv[i], "--verbose"))
            options.verbose = true;
        else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
            printf(
                "usage: pbrt [--nthreads n] [--outfile filename] [--quick] "
                "[--quiet] "
                "[--verbose] [--help] <filename.pbrt> ...\n");
            return 0;
        } else
            filenames.push_back(argv[i]);
    }

    // Print welcome banner
    if (!options.quiet) {
        printf("pbrt version 3 (built %s at %s) [Detected %d cores]\n",
               __DATE__, __TIME__, NumSystemCores());
        printf(
            "Copyright (c)1998-2015 Matt Pharr, Greg Humphreys, and Wenzel "
            "Jakob.\n");
        printf(
            "The source code to pbrt (but *not* the book contents) is covered "
            "by the BSD License.\n");
        printf("See the file LICENSE.txt for the conditions of the license.\n");
        fflush(stdout);
    }
    pbrtInit(options);
    // Process scene description
    if (filenames.size() == 0) {
        // Parse scene from standard input
        ParseFile("-");
    } else {
        // Parse scene from input files
        for (const std::string &f : filenames)
            if (!ParseFile(f))
                Error("Couldn't open scene file \"%s\"", f.c_str());
    }
    pbrtCleanup();
    return 0;
}
Example #9
0
int GModel::readGEO(const std::string &name)
{
  ParseFile(name, true);
  int imported = GModel::current()->importGEOInternals();

  return imported;
}
	QHash<QImage, QString> BaseEmoticonsSource::GetReprImages (const QString& pack) const
	{
		QHash<QImage, QString> result;

		const auto& hash = ParseFile (pack);
		const auto& uniqueImgs = hash.values ().toSet ();
		for (const auto& imgPath : uniqueImgs)
		{
			const auto& fullPath = EmoLoader_->GetIconPath (pack + "/" + imgPath);
			const auto& img = QImage { fullPath };
			if (img.isNull ())
			{
				qWarning () << Q_FUNC_INFO
						<< imgPath
						<< "in pack"
						<< pack
						<< "is null, got path:"
						<< fullPath;
				continue;
			}

			result [img] = hash.key (imgPath);
		}

		return result;
	}
Example #11
0
File: parse.c Project: Nehamkin/jwm
/** Parse an include. */
void ParseInclude(const TokenNode *tp, int depth) {

   char *temp;

   Assert(tp);

   if(JUNLIKELY(!tp->value)) {

      ParseError(tp, "no include file specified");

   } else {

      temp = CopyString(tp->value);

      ExpandPath(&temp);

      if(JUNLIKELY(!ParseFile(temp, depth))) {
         ParseError(tp, "could not open included file %s", temp);
      }

      Release(temp);

   }

}
Example #12
0
SyncLogEntry SyncLogger::ReadFirstEntry(const char* pszHash)
{
	ParseFile(pszHash);

	// Assures the correct parsing of the file.
	assert(m_pCFG != NULL);

//	cfg_t* pEntryCFG = cfg_getnsec(m_pCFG, MOD_NUMBER_VARNAME, 0);
	return ReadEntry(cfg_getnsec(m_pCFG, MOD_NUMBER_VARNAME, 0));
/*
	// Assures that the section has been found, which means there is at least one section.
    assert(pEntryCFG != NULL);

	// TODO: Copy values
	SyncLogEntry sle;
	sle.m_strFilePath = cfg_getstr(pEntryCFG, FILE_PATH_VARNAME);
	sle.m_strModTime = cfg_getstr(pEntryCFG, MOD_TIME_VARNAME);
	string strModType = cfg_getstr(pEntryCFG, MOD_TYPE_VARNAME);
	if (strModType.length() != 1)
	{
		// The log entry does not meet the standard.
		return NULL;
	}
	sle.m_chModType = strModType.c_str()[0];

    return sle;
*/
}
void CFormulaParser::ParseOpenPPLLibraryIfNeeded() {
  assert(p_function_collection != NULL);
  if (p_function_collection->OpenPPLLibraryCorrectlyParsed()) {
    write_log(preferences.debug_parser(), 
	    "[FormulaParser] OpenPPL-library already correctly loaded. Nothing to do.\n");
    return;
  }
  assert(p_filenames != NULL);
  CString openPPL_path = p_filenames->OpenPPLLibraryPath();
  if (_access(openPPL_path, F_OK) != 0) {
    // Using a message-box instead of silent logging, as OpenPPL is mandatory 
    // and we expect the user to supervise at least the first test.
    CString message;
    message.Format("Can not load \"%s\".\nFile not found.\n", openPPL_path);
    OH_MessageBox_Error_Warning(message);
    p_function_collection->SetOpenPPLLibraryLoadingState(false);
    return;
  }
  CFile openPPL_file(openPPL_path, 
    CFile::modeRead | CFile::shareDenyWrite);
  write_log(preferences.debug_parser(), 
	    "[FormulaParser] Going to load and parse OpenPPL-library\n");
  CArchive openPPL_archive(&openPPL_file, CArchive::load); 
  ParseFile(openPPL_archive);
  p_function_collection->SetOpenPPLLibraryLoadingState(CParseErrors::AnyError() == false);
}
Example #14
0
bool XML_Loader_SDL::ParseDirectory(FileSpecifier &dir)
{
  // Get sorted list of files in directory
  printf ( "Looking in %s\n", dir.GetPath() );
  vector<dir_entry> de;
  if (!dir.ReadDirectory(de)) {
    return false;
  }
  sort(de.begin(), de.end());

  // Parse each file
  vector<dir_entry>::const_iterator i, end = de.end();
  for (i=de.begin(); i!=end; i++) {
    if (i->is_directory) {
      continue;
    }
    if (i->name[i->name.length() - 1] == '~') {
      continue;
    }
    // people stick Lua scripts in Scripts/
    if (boost::algorithm::ends_with(i->name, ".lua")) {
      continue;
    }

    // Construct full path name
    FileSpecifier file_name = dir + i->name;

    // Parse file
    ParseFile(file_name);
  }

  return true;
}
Example #15
0
boolean
runScriptFile(char* pszScript, int fdCmdPipe, char* pszLogFile)
{
	int fd;
	boolean bReturn = bReturn = (fd = FileOpen(pszScript, OF_READ)) >= 0;

	if (bReturn)
	{
		/* setup file to send commands back to the parent process. */
		FILE* fpPipe = fdopen(fdCmdPipe, "wb");
		setlinebuf(fpPipe);

		/* setup file for logging. */
		FILE* fpLog = fopen(pszLogFile, "a");

		// Run the script
		UpdaterInfo ui;
		initUpdaterInfo(&ui, fpPipe, fpLog);

		bReturn = ParseFile(fd, NULL, TokenTable, FormatTable,
				parseCallback, FALSE, TRUE, TRUE, (void*) &ui);
	}

	return bReturn;
}
Example #16
0
//-------------------------------------------------------------------------
bool CVCRControl::CVCRDevice::Stop()
{
	deviceState = CMD_VCR_STOP;
	// leave scart mode
	g_RCInput->postMsg( NeutrinoMessages::VCR_OFF, 0 );
	return ParseFile(LIRCDIR "stop.lirc");
}
Example #17
0
BOOL CIVPlaybackDataBuf::ChannelTarget::Open(
    const char* pPath,
    const FILETIME& time)
{
    if ( !isValidString(pPath) )
    {
        return FALSE;
    }

    if ( m_Reader.is_open() )
    {
        m_Reader.close();
    }

    m_Reader.clear();
    string strPath = pPath;
    strPath += c_szIVFileExt;
    m_Reader.open(
        strPath.c_str(),
        ios::binary |ios::in | ios::_Nocreate );
    if ( !m_Reader.is_open() )
    {
        return FALSE;
    }

    if ( !ParseFile() )
    {
        m_Reader.close();
        return FALSE;
    }

    return MoveToAndReadSome(time);
}
Example #18
0
EffectNyquist::EffectNyquist(wxString fName)
{
   mAction = _("Applying Nyquist Effect...");
   mInputCmd = wxEmptyString;
   mCmd = wxEmptyString;
   SetEffectFlags(HIDDEN_EFFECT);
   mInteractive = false;
   mExternal = false;
   mCompiler = false;
   mDebug = false;
   mIsSal = false;
   mOK = false;

   mStop = false;
   mBreak = false;
   mCont = false;

   if (fName == wxT("")) {
      // Interactive Nyquist
      mOK = true;
      mInteractive = true;
      mName = _("Nyquist Prompt...");
      SetEffectFlags(PROCESS_EFFECT | BUILTIN_EFFECT | ADVANCED_EFFECT);
      return;
   }

   // wxLogNull dontLog; // Vaughan, 2010-08-27: Why turn off logging? Logging is good!

   mName = wxFileName(fName).GetName();
   mFileName = wxFileName(fName);
   mFileModified = mFileName.GetModificationTime();
   ParseFile();
}
Example #19
0
int main(int argc, char *argv[])
{
  int retval;
  FILE *parameter_file;

  if(argc > 1)
  {
    parameter_file = fopen(argv[1], "r");
    if(parameter_file)
    {
      ParseFile(parameter_file, parameter_printer);
      fclose(parameter_file);
      retval = 0;
    }
    else
    {
      retval=2;
    }
  }
  else
  {
    printf("Usage: %s <filename>\n", argv[0]);
    retval = 1;
  };

  return 0;
}
Example #20
0
WAVERESULT CWaves::OpenWaveFile(const char *szFilename, WAVEID *pWaveID)
{
	WAVERESULT wr = WR_OUTOFMEMORY;
	LPWAVEFILEINFO pWaveInfo;

	pWaveInfo = new WAVEFILEINFO;
	if (pWaveInfo)
	{
		if (SUCCEEDED(wr = ParseFile(szFilename, pWaveInfo)))
		{
			long lLoop = 0;
			for (lLoop = 0; lLoop < MAX_NUM_WAVEID; lLoop++)
			{
				if (!m_WaveIDs[lLoop])
				{
					m_WaveIDs[lLoop] = pWaveInfo;
					*pWaveID = lLoop;
					wr = WR_OK;
					break;
				}
			}

			if (lLoop == MAX_NUM_WAVEID)
				wr = WR_OUTOFMEMORY;
		}

		if (wr != WR_OK)
			delete pWaveInfo;
	}

	return wr;
}
Example #21
0
/**
 * Opens the file given by the filepath and returns the main node.
 * (Includes error handling)
 * @param path Filepath to the XML file to parse
 * @param tag (?)
 * @return The main XMLNode
 */
XMLNode *
XML::OpenFileHelper(const TCHAR *path)
{
  Results pResults;
  global_error = false;

  // Parse the file and get the main XMLNode
  XMLNode *xnode = ParseFile(path, &pResults);

  // If error appeared
  if (pResults.error != eXMLErrorNone) {

    // In debug mode -> Log error to stdout
#ifdef DUMP_XML_ERRORS
    printf("XML Parsing error inside file '%s'.\n"
#ifdef _UNICODE
           "Error: %S\n"
#else
           "Error: %s\n"
#endif
           "At line %u, column %u.\n", path,
           GetErrorMessage(pResults.error),
           pResults.line, pResults.column);
#endif

    // Remember Error
    global_error = true;
  }

  // Return the parsed node or empty node on error
  return xnode;
}
Example #22
0
// thread
Web::ExitCode Web::Entry()
{
	#ifdef DEBUG
		fprintf(stdout, "Start Web\n");
	#endif

	wxHTTP get;
	get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8"));
	get.SetTimeout(30); 
	
	while (!get.Connect(_T("www.workinprogress.ca"))) {
		if(TestDestroy()) {
			return (wxThread::ExitCode)0;
		} else {
			wxSleep(5);
		}
	}
		
	wxInputStream *in_stream = get.GetInputStream(whaturl);
	
	if (get.GetError() == wxPROTO_NOERR)
	{
		bool shutdownRequest = false;
		unsigned char buffer[DLBUFSIZE+1];
		do {
			Sleep(0); //http://trac.wxwidgets.org/ticket/10720
			in_stream->Read(buffer, DLBUFSIZE);
			size_t bytes_read = in_stream->LastRead();
			if (bytes_read > 0) {

				buffer[bytes_read] = 0;
				wxString buffRead((const char*)buffer, wxConvUTF8);
				m_dataRead.Append(buffRead);
			}

			// Check termination request from time to time
			if(TestDestroy()) {
				shutdownRequest = true;
				break;
			}

		} while ( !in_stream->Eof() );
		
		wxDELETE(in_stream);
		get.Close();

		if(shutdownRequest == false) {
			delete in_stream;
			ParseFile(whaturl);
		}
		
	} else {
		return (wxThread::ExitCode)0;
	}
	#ifdef DEBUG
		fprintf(stdout, "Done Web\n");	
	#endif
	
	return (wxThread::ExitCode)0; // success
}
Example #23
0
/*---------------------------------------------------------------------------
 * GetFileTitle
 * Purpose:  API to outside world to obtain the title of a file given the
 *              file name.  Useful if file name received via some method
 *              other that GetOpenFileName (e.g. command line, drag drop).
 * Assumes:  lpszFile  points to NULL terminated DOS filename (may have path)
 *           lpszTitle points to buffer to receive NULL terminated file title
 *           wBufSize  is the size of buffer pointed to by lpszTitle
 * Returns:  0 on success
 *           < 0, Parsing failure (invalid file name)
 *           > 0, buffer too small, size needed (including NULL terminator)
 *--------------------------------------------------------------------------*/
short FAR PASCAL
GetFileTitle(LPCSTR lpszFile, LPSTR lpszTitle, WORD wBufSize)
{
  short nNeeded;
  LPSTR lpszPtr;

  nNeeded = (WORD) ParseFile((ULPSTR)lpszFile);
  if (nNeeded >= 0)         /* Is the filename valid? */
    {
      if ((nNeeded = lstrlen(lpszPtr = lpszFile + nNeeded) + 1)
                                                        <= (short) wBufSize)
        {
          /* ParseFile() fails if wildcards in directory, but OK if in name */
          /* Since they aren't OK here, the check needed here               */
          if (mystrchr(lpszPtr, chMatchAny) || mystrchr(lpszPtr, chMatchOne))
            {
              nNeeded = PARSE_WILDCARDINFILE;  /* Failure */
            }
          else
            {
              lstrcpy(lpszTitle, lpszPtr);
              nNeeded = 0;  /* Success */
            }
        }
    }
  return(nNeeded);
}
Example #24
0
QStringList FipidForBank(const QString& bank)
{
  QMap<QString, QString> result;

  ParseFile(result, directory + kBankFilename, bank);
#if MSN
  ParseFile(result, directory + kCcFilename, bank);
  ParseFile(result, directory + kInvFilename, bank);
#endif

  // the fipid for Innovision is 1.
  if (bank == "Innovision")
    result["1"].clear();

  return QStringList() << result.keys();
}
	QHash<QImage, QString> BaseEmoticonsSource::GetReprImages (const QString& pack) const
	{
		QHash<QImage, QString> result;

		QSet<QString> knownPaths;
		for (const auto& pair : Util::Stlize (ParseFile (pack)))
		{
			const auto& path = pair.second;
			if (knownPaths.contains (path))
				continue;

			knownPaths << path;

			const auto& fullPath = EmoLoader_->GetIconPath (pack + "/" + path);
			const QImage img { fullPath };
			if (img.isNull ())
			{
				qWarning () << Q_FUNC_INFO
						<< path
						<< "in pack"
						<< pack
						<< "is null, got path:"
						<< fullPath;
				continue;
			}

			result [img] = pair.first;
		}

		return result;
	}
Example #26
0
int main(int argc, char **argv) {
   char tvalue = '\0', *key = calloc(ARGLENGTH, sizeof(char)),
    *parse = calloc(10, sizeof(char)),
    *fileName = calloc(ARGLENGTH, sizeof(char)), **wordList;

   tvalue = ParseArgs(argc, argv);

   key = argv[optind];
   fileName = argv[optind + 1];

   if (optind == argc || argc < 2) {
      fprintf(stderr, "usage: look [-dfa] [-t char] string [file]\n");
      exit(EXIT_FAILURE);
   }
   else if (optind + 1 == argc) {
      fileName = "/usr/share/dict/words";
      argFlags[0] = 1;
      argFlags[1] = 1;
   }
   key = CheckFlags(key, tvalue);

   ParseFile(argv, &parse, fileName);
   wordList = MakeList(parse);
   PrintResults(wordList, key, tvalue);
   return EXIT_SUCCESS;
}
void CScriptParser::SearchForFiles( const char *szWildcardPath )
{
	char filePath[FILE_PATH_MAX_LENGTH];
	char basePath[FILE_PATH_MAX_LENGTH];
	Q_strncpy( basePath, szWildcardPath, FILE_PATH_MAX_LENGTH );
	V_StripFilename( basePath );

	FileFindHandle_t findHandle;
	const char *fileName = filesystem->FindFirstEx( szWildcardPath, GetFSSearchPath(), &findHandle );
	
	while ( fileName != NULL )
	{
		Q_ComposeFileName( basePath, fileName, filePath, FILE_PATH_MAX_LENGTH );

		if( !ParseFile( filePath ) )
		{
			if ( m_bAlert )				
				DevWarning( "[script_parser] Unable to parse '%s'!\n", filePath );
		}

		fileName = filesystem->FindNext( findHandle );
	}

	filesystem->FindClose( findHandle );
}
Example #28
0
	void QueryMetaDataFile() { 
		OPENFILENAME ofn;

		char szFile[MAX_PATH];
		ZeroMemory( &ofn , sizeof(ofn));
		ofn.lStructSize = sizeof (ofn);
		ofn.hwndOwner = NULL;
		ofn.lpstrFile = szFile;
		ofn.lpstrFile[0] = '\0';
		ofn.nMaxFile = sizeof( szFile );
		ofn.lpstrFilter = "*.tbm";
		ofn.nFilterIndex = 1;
		ofn.lpstrTitle = "Select TASPlayer replay data";
		ofn.nMaxFileTitle = 0;
		ofn.lpstrInitialDir= NULL;
		ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ;
		GetOpenFileName(&ofn);

		if(*szFile) {
			ParseFile(szFile);
		}
		else {
			exit(-1337);
		}
	}
Example #29
0
//-------------------------------------------------------------------------
bool CVCRControl::CVCRDevice::Record(const t_channel_id channel_id, unsigned long long epgid, uint apid)
{
	if(channel_id != 0)		// wenn ein channel angegeben ist
	{
		if(g_Zapit->getCurrentServiceID() != channel_id)	// und momentan noch nicht getuned ist
		{
			g_Zapit->zapTo_serviceID(channel_id);		// dann umschalten
		}
	}
	if(apid !=0) //selbiges für apid
	{
 		CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo ();
		if(si.apid != apid)
		{
			printf("Setting Audio channel to %x\n",apid);
			g_Zapit->setAudioChannel(apid);
		}
	}
	deviceState = CMD_VCR_RECORD;
	// switch to scart mode
	g_RCInput->postMsg( NeutrinoMessages::VCR_ON, 0 );
/*
sendCommand(POWER
CONTROL Wait 1
IR Send CH1
CONTROL Wait 1
IR Send CH1
CONTROL Wait 1
IR Send CH0
CONTROL Wait 1
IR Send RECOTR
*/
	return ParseFile(LIRCDIR "record.lirc");
}
Example #30
0
/// ---------------------------------------------------------------------------
/// Parses the xml file.
/// ---------------------------------------------------------------------------
void prScene::ParseFile(TiXmlNode* pParent)
{
    switch (pParent->Type())
    {
    case TiXmlNode::TINYXML_ELEMENT:
        {
            // File data
            if (prStringCompare(pParent->Value(), "scene_file") == 0)
            {
                ParseAttribs_File(pParent->ToElement());
            }
            // Background data
            else if (prStringCompare(pParent->Value(), "background") == 0)
            {
                //ParseAttribs_Background(pParent->ToElement());
            }
            // Background layers
            else if (prStringCompare(pParent->Value(), "layer") == 0)
            {
                //ParseAttribs_Layer(pParent->ToElement());
            }
        }
        break;

    default:
        break;
    } 


    for (TiXmlNode *pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
    {
        ParseFile(pChild);
    }
}