Beispiel #1
0
bool JPAK::LoadFromFile(string &filename)	{
	char magic[5];
	unsigned int tableoffset;
	unsigned int fsize = 0;
	jpakfile.open(filename.c_str());
	jpakfilename = filename;
	if(jpakfile.good())	{
		jpakfile.read(magic,5);
		if(strncmp("JPAK1",magic,5) == 0)	{
			jpakfile.seekg(0,ios_base::end);
			fsize = jpakfile.tellg();
			jpakfile.seekg(-4,ios_base::end);
			jpakfile.read((char *)&tableoffset, 4);
			jpakfile.seekg(tableoffset, ios_base::beg);
			char table[fsize-tableoffset-3];
			jpakfile.read(table, fsize-tableoffset-4);
			table[fsize-tableoffset-4] = 0x00;
			string table_s = table;
			jpakfile.seekg(0,ios_base::beg);
			if(ProcessTable(table_s))	{
				ready = true;
				return true;
			}else{
				cout << "Cannot parse JPAK Table!" << endl;
				return false;
			}
		}else{
			cout << "Invalid JPAK file! " << endl;
			return false;
		}
	}else{
		cout << "Cannot open file " << filename << endl;
		return false;
	}
}
Beispiel #2
0
BOOL CStaticDataMgr::ProcessDBFile( std::string strDbFile )
{
	try
	{
		m_DBConnection.open(strDbFile.c_str());
	}
	catch(CppSQLite3Exception& e)  
	{  
		printf("%s",e.errorMessage());  
		return FALSE;
	}  

	CppSQLite3Query TableNames = m_DBConnection.execQuery("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name");
	while(!TableNames.eof())
	{
		std::string strSql ="SELECT * from ";
		std::string strTbName = TableNames.getStringField("name", NULL);
		strSql += strTbName;

		CppSQLite3Query Tabledatas = m_DBConnection.execQuery(strSql.c_str());

		ProcessTable(strTbName, Tabledatas);
		
		TableNames.nextRow();
	}
	
	m_DBConnection.close();

	return TRUE;
}
Beispiel #3
0
void processTrie(triePo trie, trieProc proc, void *cl) {
  if (trie != NULL) {
    ClRecord Cl =
      {cl, proc};
    ProcessTable(trieEntryProc, trie->follows, (void *) &Cl);
  }
}
Beispiel #4
0
retCode trieEntryProc(void *n, void *v, void *cl) {
  char K = (char) n;
  triePo T = (triePo) v;
  clPo P = (clPo) cl;

  P->proc(T->prefix, T->value, P->cl);
  if (T->follows != NULL) {
    return ProcessTable(trieEntryProc, T->follows, cl);
  }
  return Ok;
}
Beispiel #5
0
void DDF(vec_pair_GF2X_long& factors, const GF2X& ff, long verbose)
{
   GF2X f = ff;

   if (IsZero(f)) Error("DDF: bad args");

   factors.SetLength(0);

   if (deg(f) == 0)
      return;

   if (deg(f) == 1) {
      AddFactor(factors, f, 1, verbose);
      return;
   }


   long GCDTableSize = GF2X_BlockingFactor;

   GF2XModulus F;
   build(F, f);

   long i, d, limit, old_n;
   GF2X g, X;


   vec_GF2X tbl(INIT_SIZE, GCDTableSize);

   SetX(X);

   i = 0;
   SqrMod(g, X, F);
   d = 1;
   limit = GCDTableSize;


   while (2*d <= deg(f)) {

      old_n = deg(f);
      add(tbl[i], g, X);
      i++;
      if (i == limit) {
         ProcessTable(f, factors, F, i, tbl, d, verbose);
         i = 0;
      }

      d = d + 1;
      if (2*d <= deg(f)) {
         // we need to go further

         if (deg(f) < old_n) {
            // f has changed 

            build(F, f);
            rem(g, g, F);
         }

         SqrMod(g, g, F);
      }
   }

   ProcessTable(f, factors, F, i, tbl, d-1, verbose);

   if (!IsOne(f)) AddFactor(factors, f, deg(f), verbose);
}
Beispiel #6
0
void DDF(vec_pair_ZZ_pX_long& factors, const ZZ_pX& ff, const ZZ_pX& hh, 
         long verbose)
{
   ZZ_pX f = ff;
   ZZ_pX h = hh;

   if (!IsOne(LeadCoeff(f)))
      Error("DDF: bad args");

   factors.SetLength(0);

   if (deg(f) == 0)
      return;

   if (deg(f) == 1) {
      AddFactor(factors, f, 1, verbose);
      return;
   }

   long CompTableSize = 2*SqrRoot(deg(f)); 

   long GCDTableSize = ZZ_pX_BlockingFactor;

   ZZ_pXModulus F;
   build(F, f);

   ZZ_pXArgument H;

   build(H, h, F, min(CompTableSize, deg(f)));

   long i, d, limit, old_n;
   ZZ_pX g, X;


   vec_ZZ_pX tbl(INIT_SIZE, GCDTableSize);

   SetX(X);

   i = 0;
   g = h;
   d = 1;
   limit = GCDTableSize;


   while (2*d <= deg(f)) {

      old_n = deg(f);
      sub(tbl[i], g, X);
      i++;
      if (i == limit) {
         ProcessTable(f, factors, F, i, tbl, d, verbose);
         i = 0;
      }

      d = d + 1;
      if (2*d <= deg(f)) {
         // we need to go further

         if (deg(f) < old_n) {
            // f has changed 

            build(F, f);
            rem(h, h, f);
            rem(g, g, f);
            build(H, h, F, min(CompTableSize, deg(f)));
         }

         CompMod(g, g, H, F);
      }
   }

   ProcessTable(f, factors, F, i, tbl, d-1, verbose);

   if (!IsOne(f)) AddFactor(factors, f, deg(f), verbose);
}