Example #1
0
std::vector<LineInfo> ERMParser::parseFile()
{
	CERMPreprocessor preproc(srcFile);
	std::vector<LineInfo> ret;
	try
	{
		while(1)
		{
			std::string command = preproc.retreiveCommandLine();
			if(command.length() == 0)
				break;

			repairEncoding(command);
			LineInfo li;
			li.realLineNum = preproc.getCurLineNo();
			li.tl = parseLine(command, li.realLineNum);
			ret.push_back(li);
		}
	}
	catch (ParseErrorException & e)
	{
		tlog1 << "stopped parsing file" << std::endl;
	}
	return ret;
}
Example #2
0
bool schema_validator::read_config_file(const std::string &filename){
	config cfg;
	try {
		preproc_map preproc(
				game_config::config_cache::instance().get_preproc_map());
		filesystem::scoped_istream stream = preprocess_file(filename, &preproc);
		read(cfg, *stream);
	} catch(config::error& e) {
		ERR_VL << "Failed to read file "<< filename << ":\n" << e.what() << "\n";
		return false;
	}
	for(const config &g : cfg.child_range("wml_schema")) {
		for(const config &schema : g.child_range("tag")) {
			if (schema["name"].str() == "root"){
				//@NOTE Don't know, maybe merging of roots needed.
				root_ = class_tag (schema);
			}
		}
		for(const config &type : g.child_range("type")) {
			try{
				types_[type["name"].str()] = boost::regex( type["value"].str());
			}
			catch (std::exception){
			// Need to check all type values in schema-generator
			}
		}
	}

	config_read_ = true;
	return true;
}
bool schema_validator::read_config_file(const std::string &filename){
	config cfg;
	try {
		preproc_map preproc(
				game_config::config_cache::instance().get_preproc_map());
		scoped_istream stream = preprocess_file(filename, &preproc);
		read(cfg, *stream);
	} catch(config::error&) {
		return false;
	}
	BOOST_FOREACH(const config &g, cfg.child_range("wml_schema")) {
		BOOST_FOREACH(const config &schema, g.child_range("tag")) {
			if (schema["name"].str() == "root"){
				//@NOTE Don't know, maybe merging of roots needed.
				root_ = class_tag (schema);
			}
		}
		BOOST_FOREACH(const config &type, g.child_range("type")) {
			try{
				types_[type["name"].str()] = boost::regex( type["value"].str());
			}
			catch (std::exception){
			// Need to check all type values in schema-generator
			}
		}
	}

	config_read_ = true;
	return true;
}
static void kernel(pass_t * inbuffer, crack_t * outbuffer)
{

	uint32_t ipad_state[8];
	uint32_t opad_state[8];
	uint32_t tmp_out[8];
	uint32_t idx,i;
	
	for(idx=0;idx<KEYS_PER_CRYPT;idx++){
		uint8_t *pass =inbuffer[idx].v;
		uint32_t passlen=inbuffer[idx].length;
		uint8_t *salt = global_salt[0].salt;
		uint32_t saltlen=global_salt[0].length;
		uint32_t rounds=global_salt[0].rounds;

	preproc(pass, passlen, ipad_state, 0x36, 0x36363636);
#ifdef _DEBUG
	puts("ipad_state:");	
	for(i=0;i<8;i++)
		printf("%08x ",((uint32_t*)ipad_state)[i]);
	puts("");
#endif

	preproc(pass, passlen, opad_state, 0x5c, 0x5c5c5c5c);
#ifdef _DEBUG
	puts("opad_state:");	
	for(i=0;i<8;i++)
		printf("%08x ",((uint32_t*)opad_state)[i]);
	puts("");
#endif


	hmac_sha256(tmp_out, ipad_state, opad_state, salt, saltlen);
#ifdef _DEBUG
	puts("hmac_sha256:");	
	for(i=0;i<8;i++)
		printf("%08x ",((uint32_t*)tmp_out)[i]);
	puts("");
#endif
	big_hmac_sha256(tmp_out, rounds, ipad_state, opad_state,tmp_out);
	for(i=0;i<8;i++)
		outbuffer[0].hash[i] = tmp_out[i];
	}
}
Example #5
0
int main(int argc, char *argv[])
{
  cv::VideoCapture cap(0);
  // 設定しても反映されていないかもだから注意
  cap.set(CV_CAP_PROP_FRAME_WIDTH, 240);
  cap.set(CV_CAP_PROP_FRAME_HEIGHT, 160);
  // カメラがオープンできたかの確認
  if (!cap.isOpened())
  {
    return -1;
  }

  cv::namedWindow("Capture", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
  cv::namedWindow("Diff", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);

  ResultSet* result = new ResultSet();

  FILE * mylog;
  char logf[BSIZE];
  sprintf_s<BSIZE>(logf, DATA_DIR LOGFILE);
  fopen_s(&mylog, logf, "w");
  
  while (1) {
    preproc(cap, result);
    //映像が安定してから処理開始
    if (result->serial > START_FRAME)
    {
      makeDiff(result);
      result->nPix = countMat(result->diff);
      boundFace(result);
    }

    result->serial++;
    result->prev = result->gray.clone();
    //output log
    writelog(mylog, result);
    writeilog(result);
    showlog(result);

    if (result->serial > MAX_FRAME)
    {
      break;
    }
    Sleep(waitmil - WAITKEYMIL);
  }

  if (mylog != NULL)
  {
    fclose(mylog);
  }
  if (result != NULL)
  {
    delete result;
  }
  return 0;
}
Example #6
0
int run_refactor(optionst &options, messaget::mstreamt &result,
                 const symbol_tablet &st, const goto_functionst &gf)
{
    refactor_preprocessingt preproc(options, st, gf);
    refactor_symex_learnt learn_cfg(preproc.get_program());
    refactor_symex_verifyt verify_cfg(preproc.get_program());
    cegis_symex_learnt<refactor_preprocessingt, refactor_symex_learnt> learn(
        options, preproc, learn_cfg);
    cegis_symex_verifyt<refactor_symex_verifyt> oracle(options, verify_cfg);
    return run_cegis_with_statistics_wrapper(
               result, options, learn, oracle, preproc);
}
Example #7
0
void load_settings()
{
	LOG_GUI_G << "Setting: init gui.\n";

	// Init.
	twindow::update_screen_size();

	// Read file.
	config cfg;
	try
	{
		schema_validation::schema_validator validator(
				filesystem::get_wml_location("gui/schema.cfg"));
		preproc_map preproc(
				game_config::config_cache::instance().get_preproc_map());
		filesystem::scoped_istream stream = preprocess_file(
				filesystem::get_wml_location("gui/_main.cfg"), &preproc);

		read(cfg, *stream, &validator);
	}
	catch(config::error& e)
	{
		ERR_GUI_P << e.what() << '\n';
		ERR_GUI_P << "Setting: could not read file 'data/gui/_main.cfg'."
				  << std::endl;
	}
	catch(const abstract_validator::error& e)
	{
		ERR_GUI_P << "Setting: could not read file 'data/gui/schema.cfg'."
				  << std::endl;
		ERR_GUI_P << e.message;
	}
	// Parse guis
	for(const auto & g : cfg.child_range("gui"))
	{
		std::pair<std::string, tgui_definition> child;
		child.first = child.second.read(g);
		guis.insert(child);
	}

	default_gui = guis.find("default");
	VALIDATE(default_gui != guis.end(), _("No default gui defined."));

	std::string current_theme = preferences::gui_theme();
	current_gui = current_theme.empty() ? default_gui : guis.find(current_theme);
	if(current_gui == guis.end()) {
		ERR_GUI_P << "Missing [gui] definition for '" << current_theme << "'\n";
		current_gui = default_gui;
	}
	current_gui->second.activate();
}
Example #8
0
/* general syntax node traversing method */
void traverse(struct syntaxnode *node, int depth,
			void (*preproc)(struct syntaxnode *, int),
			void (*postproc)(struct syntaxnode *, int))
{
	int i;
	while (node) {
		/* itself: pre */
		preproc(node, depth);
		/* children */
		for (i = 0; node->child[i]; i++)
			traverse(node->child[i], depth + 1,
						preproc, postproc);
		/* itself: post */
		postproc(node, depth);
		/* next sibling */
		node = node->sibling;
	}
}
int main(void)
{
  int c;
  const int done = 0;     /* just a dummy for the infinite loop */
  int status = 1; /* 1 at line begin, 2 for failure, 0 otherwise */
	
  while(!done) {
    while(isspace(c = getch())) {
      putchar(c);
      if(c == '\n')
	status = 1;
    }
		
    if(c == '#' && status == 1)
      status = preproc();
		
    else if(c == '\\')
      status = backslash();
		
    else if(c == '/')
      status = comment();
		
    else if(c == '\"')
      status = literal();
		
    else if(c == EOF)
      return 0;
		
    else if(!isalpha(c) && c != '_') {
      putchar(c);
      status = 0;
    }
		
    else {
      ungetch(c);
      status = readword();
    }
		
    if(status == 2)
      return 1;
  }
  return 0;
} /* end main() */
Example #10
0
int skip(void) {
	int	c, p, nl;

	c = next();
	nl = 0;
	for (;;) {
		if (EOF == c) {
			strcpy(Text, "<EOF>");
			return EOF;
		}
		while (' ' == c || '\t' == c || '\n' == c ||
			'\r' == c || '\f' == c
		) {
			if ('\n' == c) nl = 1;
			c = next();
		}
		if (nl && c == '#') {
			preproc();
			c = next();
			continue;
		}
		nl = 0;
		if (c != '/')
			break;
		if ((c = next()) != '*') {
			putback(c);
			c = '/';
			break;
		}
		p = 0;
		while ((c = next()) != EOF) {
			if ('/' == c && '*' == p) {
				c = next();
				break;
			}
			p = c;
		}
	}
	return c;
}
Example #11
0
/*
 * Compare a string and a sort list item, according to the sort specs.
 */
int
str_list_coll(struct bwstring *str1, struct sort_list_item **ss2)
{
	struct keys_array *ka1;
	int ret = 0;

	ka1 = keys_array_alloc();

	preproc(str1, ka1);

	sort_list_item_make_key(*ss2);

	if (debug_sort) {
		bwsprintf(stdout, str1, "; s1=<", ">");
		bwsprintf(stdout, (*ss2)->str, ", s2=<", ">");
	}

	ret = key_coll(ka1, &((*ss2)->ka), 0);

	if (debug_sort)
		printf("; cmp1=%d", ret);

	clean_keys_array(str1, ka1);
	sort_free(ka1);

	if ((ret == 0) && !(sort_opts_vals.sflag) && sort_opts_vals.complex_sort) {
		ret = top_level_str_coll(str1, ((*ss2)->str));
		if (debug_sort)
			printf("; cmp2=%d", ret);
	}

	if (debug_sort)
		printf("\n");

	return (ret);
}
Example #12
0
/*
 * Calculate key for a sort list item
 */
static void
sort_list_item_make_key(struct sort_list_item *si)
{

	preproc(si->str, &(si->ka));
}
Example #13
0
/*FUNCTION*/
int ipreproc_Process(pPreprocObject pPre,
                     long lCommand,
                     void *pPointer
  ){
/*noverbatim
T<pRe> is the preprocessor object.

T<lCommand> is the command for the preprocessor to execute. For the possible
values look at the file T<prepext.h> (created from T<prepext.c>)
T<enum PreprocessorCommands>

T<pPointer> is a pointer to a structure. The structure actually depends on the
actual value of T<lCommand>. For different commands this pointer points to different
structures.

When the preprocessors are called they can alter the T<long> variable T<lCommand>
passed to them by reference.

When a preprocessor in this variable returns the value T<PreprocessorDone> the
preprocessing in the actual stage is stopped and no further proreprocessor
is invoked. However this has no effect on later preprocessor incocation.
Returning this value in this variable solely means that the preprocessor
has done all work that has to be done at the very point and thus there is
no need of further preprocessor handling.

When a preprocessor in this variable returns the value T<PreprocessorUnload>
the function unhooks the preprocessor from the list af active preprocessors,
releases all memory that the preprocessor used up and frees the library.

The return value of the preprocessor functions should be zero or error code.

The return value of the function T<ipreproc_Process> is zero or the error value of
a preprocessor. If a preprocessor returns a non-zero error code no further
preprocessors are invoked.

This function can not be used in situation when the preprocessors may return
other value in T<lCommand> than T<PreprocessorDone> or T<PreprocessorContinue>.
CUT*/
  pPreprocessor p,pn;
  long lCmd;
  int (*preproc)(void *,long *,void *);
  int iError;
  void *pDllHandle;

  p = pPre->pFirst;
  while( p ){
    lCmd = lCommand;
    preproc = p->pFunction;
    iError = preproc(&(p->pEXT),&lCmd,pPointer);
    if( lCmd == PreprocessorDone )break;
    if( lCmd == PreprocessorUnload ){
      /* unload the current preprocessor */
      pDllHandle = p->pDllHandle;
      pn = p->next;
      ipreproc_DeletePreprocessor(pPre,p);
      dynlolib_FreeLibrary(pDllHandle);
      p = pn;
      continue;
      }
    if( iError )return iError;
    p = p->next;
    }
  return COMMAND_ERROR_SUCCESS;
  }
Example #14
0
/*FUNCTION*/
int ipreproc_LoadInternalPreprocessor(pPreprocObject pPre,
                                      char *pszPreprocessorName
  ){
/*noverbatim
The first argument is the pointer to the ScriptBasic preprocessor object to access the
configuration information and the list of loaded preprocessors to put the actual one
on the list.

The second argument is the name of the preprocessor as named in the configuration file, for example

=verbatim
preproc (
  internal (
    sample "C:\\ScriptBasic\\bin\\samplepreprocessor.dll"
    )
=noverbatim

The return value is zero or the error code.

CUT*/
#define FNLEN 1024
  char szBuffer[FNLEN];
  char *s;
  void *pDllHandle = NULL,*pFunction=NULL;
  int (*preproc)(void *,long *,void *);
  pSbProgram pProgram;
  int iError;
  pPreprocessor pThisPre;
  long lCommand;
  int bFirst;
#define PREFLEN 17
  char *pszDllExtension;
  unsigned int cbDllExtension;
  CFT_NODE Node;

  pProgram = pPre->pSB;

  pszDllExtension = cft_GetString(pProgram->pCONF,"dll");
  if( pszDllExtension == NULL ){
#ifdef WIN32
    pszDllExtension = ".dll";
#elif defined(__DARWIN__)
    pszDllExtension = ".dylib";
#elif defined(__MACOS__)
    pszDllExtension = "";
#else
    pszDllExtension = ".so";
#endif
    }
  cbDllExtension = strlen(pszDllExtension);

  /* check that the preprocessor was not loaded yet */
  for( pThisPre = pPre->pFirst ; pThisPre ; pThisPre = pThisPre->next )
    if( !strcmp(pThisPre->pszPreprocessorName,pszPreprocessorName) )return COMMAND_ERROR_SUCCESS;

  strcpy(szBuffer,"preproc.internal.");
  if( strlen(pszPreprocessorName) > FNLEN - PREFLEN )return READER_ERROR_PREPROC_LONG;
  strcpy(szBuffer+PREFLEN,pszPreprocessorName);
  s = szBuffer+PREFLEN;
  while( *s && ! isspace(*s) )s++; /* chop off optional parameters and/or NL from the end of line */
  *s = (char)0;
  s = cft_GetString(pProgram->pCONF,szBuffer);
  /* if the internal preprocessor was not configured then it still can be used if the DLL or SO file
     is copied into the modules library. */
  if( NULL == s ){
      if( ! cft_GetEx(pProgram->pCONF,"module",&Node,&s,NULL,NULL,NULL) ){
        while( 1 ){
          if( cft_GetEx(pProgram->pCONF,NULL,&Node,&s,NULL,NULL,NULL) ){
            /* if there are no more directories in the configuration */
            break;
            }
          if( ! strcmp(cft_GetKey(pProgram->pCONF,Node),"module") ){
            if( strlen(s) + strlen(pszPreprocessorName) > FNLEN )return READER_ERROR_PREPROC_LONG;
            strcpy(szBuffer,s);
            strcat(szBuffer,pszPreprocessorName);
            if( strlen(szBuffer) + cbDllExtension > FNLEN )return READER_ERROR_PREPROC_LONG;
            strcat(szBuffer,pszDllExtension);
            pDllHandle = dynlolib_LoadLibrary( szBuffer );
            if( pDllHandle != NULL )break;
            }
          Node = cft_EnumNext(pProgram->pCONF,Node);
          }
        }
    }else{
    /* if the preprocessor was configured in the config file
       not only copied into one of the module directories */
    pDllHandle = dynlolib_LoadLibrary(s);
    }
  if( pDllHandle == NULL )return READER_ERROR_PREPROC_NOTAVA;

  pFunction = dynlolib_GetFunctionByName(pDllHandle,"preproc");
  if( pFunction == NULL )return READER_ERROR_PREPROC_NOTVAL;

  bFirst = (pPre->pFirst == NULL);
  pThisPre = ipreproc_InsertPreprocessor(pPre);
  if( pThisPre == NULL  )return COMMAND_ERROR_MEMORY_LOW;
  pThisPre->pszPreprocessorName = alloc_Alloc(strlen(pszPreprocessorName)+1,pPre->pMemorySegment);
  if( pThisPre->pszPreprocessorName == NULL )return COMMAND_ERROR_MEMORY_LOW;

  strcpy(pThisPre->pszPreprocessorName,pszPreprocessorName);
  pThisPre->pDllHandle = pDllHandle;
  pThisPre->pFunction = pFunction;
  pThisPre->pEXT.lVersion = IP_INTERFACE_VERSION;
  pThisPre->pEXT.pPointer = NULL;
  pThisPre->pEXT.pMemorySegment = alloc_InitSegment(pPre->pSB->maf,pPre->pSB->mrf);
  if( pThisPre->pEXT.pMemorySegment == NULL )return COMMAND_ERROR_MEMORY_LOW;

  /* if this is the first preprocessor loaded then init
     the support function table*/
  if( bFirst ){
    pPre->EXE.pMemorySegment = pPre->pMemorySegment;
    modu_Init(&(pPre->EXE),0);
    pPre->EXE.pST->pEo = &(pPre->EXE);
    pThisPre->pEXT.pST = pPre->EXE.pST;
    }

  preproc = pFunction;
  lCommand = PreprocessorLoad;
  iError = preproc(&(pThisPre->pEXT),&lCommand,NULL);
  if( lCommand == PreprocessorUnload ){
    /* unload the current preprocessor */
    pDllHandle = pThisPre->pDllHandle;
    ipreproc_DeletePreprocessor(pPre,pThisPre);
    /* this may happen if the preprocessor is statically linked */
    if( pDllHandle )
      dynlolib_FreeLibrary(pDllHandle);
    }
  return iError;
  }
Example #15
0
//dz 5.28.14
int ipreproc_LoadInternalPreprocessorByFunction(pPreprocObject pPre, char* pszPreprocessorName, void* lpfnPreProc)
{
//The return value is zero or the error code.
#define FNLEN 1024
  char szBuffer[FNLEN];
  char *s;
  void *pDllHandle = NULL,*pFunction=NULL;
  int (*preproc)(void *,long *,void *);
  pSbProgram pProgram;
  int iError;
  pPreprocessor pThisPre;
  long lCommand;
  int bFirst;
#define PREFLEN 17
  char *pszDllExtension;
  unsigned int cbDllExtension;

  pProgram = pPre->pSB;

  /* check that the preprocessor was not loaded yet */
  for( pThisPre = pPre->pFirst ; pThisPre ; pThisPre = pThisPre->next )
    if( !strcmp(pThisPre->pszPreprocessorName,pszPreprocessorName) )return COMMAND_ERROR_SUCCESS;

  pFunction = lpfnPreProc;
  if( pFunction == NULL )return READER_ERROR_PREPROC_NOTVAL;

  bFirst = (pPre->pFirst == NULL);
  pThisPre = ipreproc_InsertPreprocessor(pPre);
  if( pThisPre == NULL  )return COMMAND_ERROR_MEMORY_LOW;
  pThisPre->pszPreprocessorName = alloc_Alloc(strlen(pszPreprocessorName)+1,pPre->pMemorySegment);
  if( pThisPre->pszPreprocessorName == NULL )return COMMAND_ERROR_MEMORY_LOW;

  strcpy(pThisPre->pszPreprocessorName,pszPreprocessorName);
  pThisPre->pDllHandle = 0;
  pThisPre->pFunction = pFunction;
  pThisPre->pEXT.lVersion = IP_INTERFACE_VERSION;
  pThisPre->pEXT.pPointer = NULL;
  pThisPre->pEXT.pMemorySegment = alloc_InitSegment(pPre->pSB->maf,pPre->pSB->mrf);
  if( pThisPre->pEXT.pMemorySegment == NULL )return COMMAND_ERROR_MEMORY_LOW;

  /* if this is the first preprocessor loaded then init the support function table*/
  if( bFirst ){
    pPre->EXE.pMemorySegment = pPre->pMemorySegment;
    modu_Init(&(pPre->EXE),0);
    pPre->EXE.pST->pEo = &(pPre->EXE);
    pThisPre->pEXT.pST = pPre->EXE.pST;
  }

  preproc = pFunction;
  lCommand = PreprocessorLoad;
  iError = preproc(&(pThisPre->pEXT),&lCommand,NULL);
  if( lCommand == PreprocessorUnload ){
    /* unload the current preprocessor */
    pDllHandle = pThisPre->pDllHandle;
    ipreproc_DeletePreprocessor(pPre,pThisPre);
    /* this may happen if the preprocessor is statically linked */
    if( pDllHandle )
      dynlolib_FreeLibrary(pDllHandle);
    }
  return iError;
}