Example #1
0
void CACHE_SESSION::unserialize_bin(char *bin)
{
	// zend_printf("CACHE_SESSION::unserialize_bin()\n");
	unsigned long *p = (unsigned long *)bin;
	this->session_id = p[0];
	unsigned long nbases = p[1];
	p += 2;
	CACHE_BASE *cb;
	while(nbases--)
	{
		long base_id = *p++;
		long sbas_id = *p++;
		bool online = *p++ ? true : false;
		char *viewname = (char *)p;
		p += LSTRPAD(strlen(viewname)) / sizeof(long);
		char *host = (char *)p;
		p += LSTRPAD(strlen(host)) / sizeof(long);
		long port = *p++;
		char *user = (char *)p;
		p += LSTRPAD(strlen(user)) / sizeof(long);
		char *passwd = (char *)p;
		p += LSTRPAD(strlen(passwd)) / sizeof(long);
		long engine = *p++;
		char *dbname = (char *)p;
		p += LSTRPAD(strlen(dbname)) / sizeof(long);
		char *xmlstruct = (char *)p;
		p += LSTRPAD(strlen(xmlstruct)) / sizeof(long);
		unsigned long ncoll = *p++;

		cb = this->addbase(base_id, host, port, user, passwd, dbname, xmlstruct, sbas_id, viewname, online);

		while(ncoll--)
		{
		  int l;
			long coll_id = *p++;

			long base_id = *p++;

		//	long phserver_port = *p++;
			long registered = *p++;

			char *name = (char *)p;
			l = LSTRPAD(strlen(name));
			p += l/sizeof(long);
#if GETPREFS

			char *prefs = (char *)p;
			l = LSTRPAD(strlen(prefs));
			p += l/sizeof(long);
#endif
			//	char *phserver_host = (char *)p;
		//	l = LSTRPAD(strlen(phserver_host));
		//	p += l/sizeof(long);

	//		cb->addcoll(coll_id, base_id, name, phserver_host, phserver_port, registered ? true : false);
			cb->addcoll(coll_id, base_id, name, prefs, registered ? true : false);

		}
	}
}
CACHE_COLL::CACHE_COLL(long coll_id, long base_id, char *name, char *prefs) //, bool registered)
{
  int lstr, lram;
	this->coll_id = coll_id;
	this->base_id = base_id;
	this->name = NULL;
	this->name_lenPAD = 0;
	this->prefs = NULL;
	this->prefs_lenPAD = 0;
//	this->registered = registered;
	this->binsize = sizeof(this->coll_id)			// coll_id
					+ sizeof(this->base_id)			// base_id
//					+ sizeof(this->phserver_port)	// phserver_port
//					+ sizeof(long)					// registered
					+ PAD							// name	(if null)
#if GETPREFS
					+ PAD							// prefs (if null)
#endif
					;
	if(name)
	{
		lstr = strlen(name);
		lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->name = (char *)EMALLOC(lram))
		{
			this->name_lenPAD = lram;
			memcpy(this->name, name, lstr+1);
			while(lstr<lram)
				this->name[lstr++] = '\0';	// pad with 0
			this->binsize += lram-PAD;		// PAD was already counted
		}
	}
#if GETPREFS
	if(prefs)
	{
		lstr = strlen(prefs);
		lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->prefs = (char *)EMALLOC(lram))
		{
			this->prefs_lenPAD = lram;
			memcpy(this->prefs, prefs, lstr+1);
			while(lstr<lram)
				this->prefs[lstr++] = '\0';	// pad with 0
			this->binsize += lram-PAD;		// PAD was already counted
		}
	}
#endif
	this->nextcoll = NULL;
}
Example #3
0
CACHE_BASE::CACHE_BASE(long base_id, char *host, long port, char *user, char *passwd, char *dbname, char *xmlstruct, long sbas_id, char *viewname, bool online)
{
//	zend_printf("NEW BASE\n");
	this->online = online;
 	this->base_id = base_id;
 	this->sbas_id = sbas_id;
	this->port = port;
	this->engine = PHRASEA_MYSQLENGINE;
	this->conn = NULL;

	this->viewname = NULL;
	this->viewname_lenPAD = PAD;
	if(viewname)
	{
		long lstr = strlen(viewname);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->viewname = (char *)EMALLOC(lram))
		{
			this->viewname_lenPAD = lram;
			memcpy(this->viewname, viewname, lstr+1);
			while(lstr<lram)
				this->viewname[lstr++] = '\0';	// on compl�te avec des 0
		}
	}

	this->host = NULL;
	this->host_lenPAD = PAD;
	if(host)
	{
		long lstr = strlen(host);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->host = (char *)EMALLOC(lram))
		{
			this->host_lenPAD = lram;
			memcpy(this->host, host, lstr+1);
			while(lstr<lram)
				this->host[lstr++] = '\0';	// on compl�te avec des 0
		}
	}

	this->user = NULL;
	this->user_lenPAD = PAD;
	if(user)
	{
		long lstr = strlen(user);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->user = (char *)EMALLOC(lram))
		{
			this->user_lenPAD = lram;
			memcpy(this->user, user, lstr+1);
			while(lstr<lram)
				this->user[lstr++] = '\0';	// on compl�te avec des 0
		}
	}

	this->passwd = NULL;
	this->passwd_lenPAD = PAD;
	if(passwd)
	{
		long lstr = strlen(passwd);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->passwd = (char *)EMALLOC(lram))
		{
			this->passwd_lenPAD = lram;
			memcpy(this->passwd, passwd, lstr+1);
			while(lstr<lram)
				this->passwd[lstr++] = '\0';	// on compl�te avec des 0
		}
	}

	this->dbname = NULL;
	this->dbname_lenPAD = PAD;
	if(dbname)
	{
		long lstr = strlen(dbname);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->dbname = (char *)EMALLOC(lram))
		{
			this->dbname_lenPAD = lram;
			memcpy(this->dbname, dbname, lstr+1);
			while(lstr<lram)
				this->dbname[lstr++] = '\0';	// on compl�te avec des 0
		}
	}

	this->xmlstruct = NULL;
	this->xmlstruct_lenPAD = PAD;
	if(xmlstruct)
	{
		long lstr = strlen(xmlstruct);
		long lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->xmlstruct = (char *)EMALLOC(lram))
		{
			this->xmlstruct_lenPAD = lram;
			memcpy(this->xmlstruct, xmlstruct, lstr+1);
			while(lstr<lram)
				this->xmlstruct[lstr++] = '\0';	// on compl�te avec des 0
		}
	}
	this->binsize = sizeof(this->base_id)			// base_id
					+ sizeof(this->sbas_id)			// sbas_id
					+ sizeof(long)					// online
					+ this->viewname_lenPAD			// viewname
					+ this->host_lenPAD				// host
					+ sizeof(this->port)			// port
					+ this->user_lenPAD				// user
					+ this->passwd_lenPAD				// pwd
					+ sizeof(this->engine)			// engine
					+ this->dbname_lenPAD				// dbname
					+ this->xmlstruct_lenPAD			// xmlstruct
					+ sizeof(long);					// nombre de coll
	this->firstcoll = NULL;
	this->nextbase = NULL;
}
Example #4
0
CACHE_COLL::CACHE_COLL(long coll_id, long base_id, char *name, char *prefs, bool registered)
{
// zend_printf("NEW COLL\n");
  int lstr, lram;
//  zend_printf("coll_id='%li', base_id='%li', name='%s', prefs='%s'<br>\n", coll_id, base_id, name, (prefs?prefs:"null") );
	this->coll_id = coll_id;
	this->base_id = base_id;
//	this->phserver_port = phserver_port;
	this->name = NULL;
	this->name_lenPAD = 0;
	this->prefs = NULL;
	this->prefs_lenPAD = 0;
//	this->phserver_host = NULL;
//	this->phserver_host_lenPAD = 0;
	this->registered = registered;
	this->binsize = sizeof(this->coll_id)			// coll_id
					+ sizeof(this->base_id)			// base_id
//					+ sizeof(this->phserver_port)	// phserver_port
					+ sizeof(long)					// registered
					+ PAD								// name	(si null)
#if GETPREFS
					+ PAD								// prefs	(si null)
#endif
					;
//					+ PAD;							// phserver_host (si null)
	if(name)
	{
		lstr = strlen(name);
		lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->name = (char *)EMALLOC(lram))
		{
			this->name_lenPAD = lram;
			memcpy(this->name, name, lstr+1);
			while(lstr<lram)
				this->name[lstr++] = '\0';	// on compl�te avec des 0
			this->binsize += lram-PAD;	// on avait d�j� compt� PAD
		}
	}
#if GETPREFS
	if(prefs)
	{
		lstr = strlen(prefs);
		lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
		if(this->prefs = (char *)EMALLOC(lram))
		{
			this->prefs_lenPAD = lram;
			memcpy(this->prefs, prefs, lstr+1);
			while(lstr<lram)
				this->prefs[lstr++] = '\0';	// on compl�te avec des 0
			this->binsize += lram-PAD;	// on avait d�j� compt� PAD
		}
	}
#endif
//	if(phserver_host)
//	{
//		lstr = strlen(phserver_host);
//		lram = LSTRPAD(lstr);			// place pour le '\0' final, arrondi au multiple de PAD sup�rieur
//		if(this->phserver_host = (char *)EMALLOC(lram))
//		{
//			this->phserver_host_lenPAD = lram;
//			memcpy(this->phserver_host, phserver_host, lstr+1);
//			while(lstr<lram)
//				this->phserver_host[lstr++] = '\0';	// on compl�te avec des 0
//			this->binsize += lram-PAD;	// on avait d�j� compt� PAD
//		}
//	}
	this->nextcoll = NULL;
}
CACHE_BASE::CACHE_BASE(long base_id, char *host, long port, char *user, char *passwd, char *dbname, char *xmlstruct, long sbas_id, char *viewname) //, bool online)
{
//	this->online = online;
 	this->base_id = base_id;
 	this->sbas_id = sbas_id;
	this->port = port;
//	this->engine = PHRASEA_MYSQLENGINE;
	this->conn = NULL;

	this->viewname = NULL;
	this->viewname_lenPAD = PAD;
	if(viewname)
	{
		long lstr = strlen(viewname);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->viewname = (char *)EMALLOC(lram))
		{
			this->viewname_lenPAD = lram;
			memcpy(this->viewname, viewname, lstr+1);
			while(lstr<lram)
				this->viewname[lstr++] = '\0';	// pad with 0
		}
	}

	this->host = NULL;
	this->host_lenPAD = PAD;
	if(host)
	{
		long lstr = strlen(host);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->host = (char *)EMALLOC(lram))
		{
			this->host_lenPAD = lram;
			memcpy(this->host, host, lstr+1);
			while(lstr<lram)
				this->host[lstr++] = '\0';	// pad with 0
		}
	}

	this->user = NULL;
	this->user_lenPAD = PAD;
	if(user)
	{
		long lstr = strlen(user);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->user = (char *)EMALLOC(lram))
		{
			this->user_lenPAD = lram;
			memcpy(this->user, user, lstr+1);
			while(lstr<lram)
				this->user[lstr++] = '\0';	// pad with 0
		}
	}

	this->passwd = NULL;
	this->passwd_lenPAD = PAD;
	if(passwd)
	{
		long lstr = strlen(passwd);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->passwd = (char *)EMALLOC(lram))
		{
			this->passwd_lenPAD = lram;
			memcpy(this->passwd, passwd, lstr+1);
			while(lstr<lram)
				this->passwd[lstr++] = '\0';	// pad with 0
		}
	}

	this->dbname = NULL;
	this->dbname_lenPAD = PAD;
	if(dbname)
	{
		long lstr = strlen(dbname);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->dbname = (char *)EMALLOC(lram))
		{
			this->dbname_lenPAD = lram;
			memcpy(this->dbname, dbname, lstr+1);
			while(lstr<lram)
				this->dbname[lstr++] = '\0';	// pad with 0
		}
	}

	this->xmlstruct = NULL;
	this->xmlstruct_lenPAD = PAD;
	if(xmlstruct)
	{
		long lstr = strlen(xmlstruct);
		long lram = LSTRPAD(lstr);			// room for the final '\0', rounded to the next multiple of PAD
		if(this->xmlstruct = (char *)EMALLOC(lram))
		{
			this->xmlstruct_lenPAD = lram;
			memcpy(this->xmlstruct, xmlstruct, lstr+1);
			while(lstr<lram)
				this->xmlstruct[lstr++] = '\0';		// pad with 0
		}
	}
	this->binsize = sizeof(this->base_id)			// base_id
					+ sizeof(this->sbas_id)			// sbas_id
//					+ sizeof(this->online)			// online
					+ this->viewname_lenPAD			// viewname
					+ this->host_lenPAD				// host
					+ sizeof(this->port)			// port
					+ this->user_lenPAD				// user
					+ this->passwd_lenPAD			// pwd
//					+ sizeof(this->engine)			// engine
					+ this->dbname_lenPAD			// dbname
					+ this->xmlstruct_lenPAD		// xmlstruct
					+ sizeof(long);					// count of collections
	this->firstcoll = NULL;
	this->nextbase = NULL;
}