Exemple #1
0
/**
 * Reads opcodes from file.
 */
uint8_t* read_script(string file, int *len) {
   vector<string> tokens = tokenize_file(file, len);
   vector<uint8_t> instructions = convert_inst(tokens);
   uint8_t* ret = new uint8_t[instructions.size()];
   for(int i=0; i<instructions.size(); i++) {
      ret[i] = instructions[i];
      //cout << "ret[" << i << "] = " << (int)ret[i] << endl;
   }
   return ret;
}
Exemple #2
0
/*
 * read in hba config file
 */
void load_hba(char *hbapath)
{
	FILE *file;

	POOL_MEMORY_POOL *old_context;
	if (hba_memory_context == NULL)
	{
		hba_memory_context = pool_memory_create(PARSER_BLOCK_SIZE);
		if (hba_memory_context == NULL)
		{
			pool_error("load_hba: pool_memory_create() failed");
			exit(1);
		}
	}
	/* switch memory context */
	old_context = pool_memory;
	pool_memory = hba_memory_context;

	if (hba_lines || hba_line_nums)
		free_lines(&hba_lines, &hba_line_nums);

	file = fopen(hbapath, "r");
	if (!file)
	{
		pool_error("could not open \"%s\". reason: %s",
				   hbapath, strerror(errno));
		exit(1);
	}

	pool_debug("loading \"%s\" for client authentication configuration file",
			   hbapath);

	tokenize_file(hbapath, file, &hba_lines, &hba_line_nums);
	fclose(file);

	hbaFileName = pstrdup(hbapath);

	/* switch old memory context */
	pool_memory = old_context;
}