static void zpokel(struct zatm_dev *zatm_dev,u32 value,u32 addr)
{
	zwait;
	zout(value,CER);
	zout(uPD98401_IND_ACC | uPD98401_IA_BALL |
	    (uPD98401_IA_TGT_CM << uPD98401_IA_TGT_SHIFT) | addr,CMR);
}
	void next_k(int inNumSamples)
	{
		float newFreq        = in0(1);
		float newQ           = in0(2);
		float newHPCutoff    = in0(3);

		if (q != newQ)
			set_q(newQ);

		if (newHPCutoff != hpCutoff)
			setFeedbackHPF(newHPCutoff * sampleDur());

		double a, a_inv, a2, b, b2, c, g, g0;
		calcFilterCoefficients(newFreq, a, a2, a_inv, b, b2, c, g, g0);

		double z0 = z[0];
		double z1 = z[1];
		double z2 = z[2];
		double z3 = z[3];
		double z4 = z[4];

		const float * inSig = zin(0);
		float * outSig = zout(0);

		for (int i = 0; i != inNumSamples; ++i) {
			double x = ZXP(inSig);
			ZXP(outSig) = tick(x, a, a2, a_inv, b, b2, c, g, g0, z0, z1, z2, z3, z4);
		}
		z[0] = z0;
		z[1] = z1;
		z[2] = z2;
		z[3] = z3;
		z[4] = z4;
	}
Example #3
0
OSG_USING_NAMESPACE

int main (int argc, char **argv)
{
    std::stringstream compressed(std::stringstream::in | std::stringstream::out);

    // with false we add no gzip header and footer.
    zip_ostream zout(compressed, false);
    
    zout << std::string("Begin")
         << " " << Int32(123456789)
         << " " << Real32(1.41232)
         << " " << std::string("End");

    // this flushes the stream and adds the gzip footer, this is
    // done automatically in the zip_ostream destructor, but in this
    // case we need to call it directly!
    zout.finished();

    std::cout << "Compressed  : " << "'" << compressed.str() << "' (" << compressed.str().size() << ")" << std::endl;

    std::string str1;
    Int32 v1 = 0;
    Real32 v2 = 0.0f;
    std::string str2;

    zip_istream zin(compressed);
    zin >> str1 >> v1 >> v2 >> str2;

    std::cout << "Uncompressed: " << "'" << str1 << "' " << v1 << " " << v2
                                  << " '" << str2 << "'" << std::endl;

    return 0;
}
static u32 zpeekl(struct zatm_dev *zatm_dev,u32 addr)
{
	zwait;
	zout(uPD98401_IND_ACC | uPD98401_IA_BALL | uPD98401_IA_RW |
	  (uPD98401_IA_TGT_CM << uPD98401_IA_TGT_SHIFT) | addr,CMR);
	zwait;
	return zin(CER);
}
Example #5
0
	~Log()
	{
		if (_messages.size() <= 1) {
			return;
		}

		// Build the file name for storing this game
		auto file = Helper::GetUserDataDir();
		file.SetFullName(wxString::Format("%i.hsl", int(_messages[0].first / int(1e9))));
		file.AppendDir("Logged");
		auto filename = file.GetFullPath();
		wxLogVerbose("saving %d messages to %s", _messages.size() - 1, filename);

		// Create the containing directory if needed
		if (!file.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) {
			wxLogError("error creating save directory: %s", filename);
			return;
		}

		// This should't happen, but check and log just in case
		if (file.Exists()) {
			wxLogWarning("overwriting existing game: %s", filename);
		}

		// Open the file
		wxFileOutputStream fout(file.GetFullPath());
		if (!fout.Ok()) {
			wxLogError("error opening file: %s", filename);
			return;
		}

		// Zip the data while saving it to save some bandwidth later when the file is uploaded
		wxZlibOutputStream zout(fout, wxZ_BEST_COMPRESSION, wxZLIB_NO_HEADER);

		// Add header info
		// <nanotime>
		// 48 53 4C 48 09 00 00 00 
		// 09 XX XX XX XX XX XX XX XX
		auto version = Helper::GetHearthstoneVersion();
		zout.Write(&_messages[0].first, 8)
			.Write("HSLH\t\0\0\0\t", 9) // HSLH 09000000 09
			.Write(&version, 8);

		// Add the rest of the data
		auto size = 25;
		for (auto i = 1u; i < _messages.size(); i++) {
			auto time = _messages[i].first;
			auto msg = _messages[i].second;

			size += 8 + msg.size();
			zout.Write(&time, 8).Write(msg.data(), msg.size());
		}
		zout.Close();
		wxLogVerbose("saved %d messages from %s (%d bytes, %lld compressed)", _messages.size() - 1, _name, size, fout.GetLength());

		// Notify the app that it can upload the log file
		HearthLogApp::UploadLog(filename);
	}
Example #6
0
void GameBoard::addInterpreter( ZZTOOP::Interpreter *interp )
{
  // Gameboard owns the programs, not the Scriptable Objects
  d->programs.push_back( interp );

#if 0
  zdebug() << "GameBoard::addProgramBank" << prog << prog->length();
  zout() << "\n";
  for ( signed short i = 0; i < prog->length(); i++ ) {
    signed char c = (*prog)[i];
    if ( c == 0x0d ) zout() << " \\n ";
    else if ( c >= ' ' ) zout() << ZString(1, c);
    else zout() << "?";
  }

  zout() << "\n";
#endif
}
static void refill_pool(struct atm_dev *dev,int pool)
{
	struct zatm_dev *zatm_dev;
	struct sk_buff *skb;
	struct rx_buffer_head *first;
	unsigned long flags;
	int align,offset,free,count,size;

	EVENT("refill_pool\n",0,0);
	zatm_dev = ZATM_DEV(dev);
	size = (64 << (pool <= ZATM_AAL5_POOL_BASE ? 0 :
	    pool-ZATM_AAL5_POOL_BASE))+sizeof(struct rx_buffer_head);
	if (size < PAGE_SIZE) {
		align = 32; /* for 32 byte alignment */
		offset = sizeof(struct rx_buffer_head);
	}
	else {
		align = 4096;
		offset = zatm_dev->pool_info[pool].offset+
		    sizeof(struct rx_buffer_head);
	}
	size += align;
	spin_lock_irqsave(&zatm_dev->lock, flags);
	free = zpeekl(zatm_dev,zatm_dev->pool_base+2*pool) &
	    uPD98401_RXFP_REMAIN;
	spin_unlock_irqrestore(&zatm_dev->lock, flags);
	if (free >= zatm_dev->pool_info[pool].low_water) return;
	EVENT("starting ... POOL: 0x%x, 0x%x\n",
	    zpeekl(zatm_dev,zatm_dev->pool_base+2*pool),
	    zpeekl(zatm_dev,zatm_dev->pool_base+2*pool+1));
	EVENT("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
	count = 0;
	first = NULL;
	while (free < zatm_dev->pool_info[pool].high_water) {
		struct rx_buffer_head *head;

		skb = alloc_skb(size,GFP_ATOMIC);
		if (!skb) {
			printk(KERN_WARNING DEV_LABEL "(Itf %d): got no new "
			    "skb (%d) with %d free\n",dev->number,size,free);
			break;
		}
		skb_reserve(skb,(unsigned char *) ((((unsigned long) skb->data+
		    align+offset-1) & ~(unsigned long) (align-1))-offset)-
		    skb->data);
		head = (struct rx_buffer_head *) skb->data;
		skb_reserve(skb,sizeof(struct rx_buffer_head));
		if (!first) first = head;
		count++;
		head->buffer = virt_to_bus(skb->data);
		head->link = 0;
		head->skb = skb;
		EVENT("enq skb 0x%08lx/0x%08lx\n",(unsigned long) skb,
		    (unsigned long) head);
		spin_lock_irqsave(&zatm_dev->lock, flags);
		if (zatm_dev->last_free[pool])
			((struct rx_buffer_head *) (zatm_dev->last_free[pool]->
			    data))[-1].link = virt_to_bus(head);
		zatm_dev->last_free[pool] = skb;
		skb_queue_tail(&zatm_dev->pool[pool],skb);
		spin_unlock_irqrestore(&zatm_dev->lock, flags);
		free++;
	}
	if (first) {
		spin_lock_irqsave(&zatm_dev->lock, flags);
		zwait;
		zout(virt_to_bus(first),CER);
		zout(uPD98401_ADD_BAT | (pool << uPD98401_POOL_SHIFT) | count,
		    CMR);
		spin_unlock_irqrestore(&zatm_dev->lock, flags);
		EVENT ("POOL: 0x%x, 0x%x\n",
		    zpeekl(zatm_dev,zatm_dev->pool_base+2*pool),
		    zpeekl(zatm_dev,zatm_dev->pool_base+2*pool+1));
		EVENT("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
	}
}
int main(int argc, char* argv[])
{
	TExeTm ExeTm;
	PGconn *conn;
	PGresult *res;
	int id,start,rec_count,row,indx,end;
	unsigned int q;
	int total_number_tweets = 0;
	double tweet_date = 0;
	TStr TweetStr("");
	TStr TweetStrLc("");

	if(argc > 1)
	{
		start = atoi(argv[1]);
	}
	else
	{
		printf("YOU SHOULD SET THE INDICES...\n\n");
		return 1;
	}
	indx = start * LENGTH;
	end = indx + LENGTH;

	printf(":::::::: Find Cascades of Quotes In Twitter Separately ::::::::\n");
	const TStr StartDate = Env.GetIfArgPrefixStr("-sd:", "2008-08-01 00:00:00", "Starting date");
	const TStr EndDate = Env.GetIfArgPrefixStr("-ed:", "2009-10-01 00:00:00", "Ending date");

	Env = TEnv(argc, argv, TNotify::StdNotify);
	Env.PrepArgs(TStr::Fmt("\nFinding the cascades of the desired quotes. build: %s, %s. Time: %s", __TIME__, __DATE__, TExeTm::GetCurTm()));
	try
	{
		while(indx < end)
		{
			TStr qContentFname = TStr::Fmt("QuotesData/Q%d.rar",indx);
			TStr resultFname = TStr::Fmt("QuotesCascResult/R%d.rar",indx++);

			if(fileExists(resultFname))
			{
				if(fileExists(qContentFname))
				{
					// removing the quotes' content file
					system(TStr::Fmt("rm %s",qContentFname.CStr()).CStr());
				}
			}
			else
			{
				if(fileExists(qContentFname))
				{
					THash<TStr,TInt> quotesContent;
					THash<TInt,TSecTmV> CascadesOnTwitter;

					TZipIn ZquotesIn(qContentFname);
					quotesContent.Load(ZquotesIn);
					printf("Q%d loading done, it contains %d quotes.\n",indx-1,quotesContent.Len());

					conn = PQconnectdb("dbname=twitter host=postgresql01.mpi-sws.org user=twitter password=tweet@84");

					if (PQstatus(conn) == CONNECTION_BAD)
					{
						printf("We were unable to connect to the database");
						return 1;
					}

					// we use cursors/fetch to speed up the process; batch of 10000 tweets
					PQexec(conn, "begin work");
					PQexec(conn,TStr::Fmt("declare mycursor cursor for select tweettext, extract(epoch from tweettime) from tweets where tweettime >= timestamp '%s' and tweettime < timestamp '%s'", StartDate.CStr(), EndDate.CStr()).CStr());

					do
					{
						res = PQexec(conn, "FETCH 1000000 IN mycursor");    // all of them are: 1675401026
						if (PQresultStatus(res) == PGRES_TUPLES_OK)
						{
							rec_count = PQntuples(res);
							total_number_tweets += rec_count;
							printf("Adding %d tweets... (total: %d)\n", rec_count, total_number_tweets);

							for (row=0; row<rec_count; row++)
							{
								TweetStr = PQgetvalue(res, row, 0);
								tweet_date = TStr(PQgetvalue(res, row, 1)).GetFlt();
								TweetStrLc = TweetStr.ToLc();
								for(q=0;q<quotesContent.Len();q++)
								{
									if (TweetStrLc.SearchStr(quotesContent.GetKey(q)) > -1)
									{
										TSecTm td(tweet_date);
										id = CascadesOnTwitter.GetKeyId(quotesContent[q]);
										if(id == -1)
										{
											CascadesOnTwitter.AddDat(quotesContent[q]).Add(td);
										}
										else
										{
											CascadesOnTwitter.GetDat(quotesContent[q]).AddSorted(td);
										}
									}
								}
							}

							PQclear(res);
						}
						else
						{
							rec_count = 0;
						}
					}
					while (rec_count);

					PQexec(conn, "close mycursor");
					PQexec(conn, "commit work");
					PQfinish(conn);


					// Save the results
					TZipOut zout(resultFname);
					CascadesOnTwitter.Save(zout);

					// Remove the qoutes' content file
					system(TStr::Fmt("rm %s",qContentFname.CStr()).CStr());
				}
			}
		}

		printf("\n\nD O N E\n\n");
	}
	catch(exception& ex)
	{
		printf("\nError1 happened, it was: %s\n\n",ex.what());
	}
	catch(TPt<TExcept>& ex)
	{
		printf("\nError2 happened: %s\n\n",ex[0].GetStr().CStr());
	}

	printf("\nrun time: %s (%s)\n", ExeTm.GetTmStr(), TSecTm::GetCurTm().GetTmStr().CStr());
	return 0;
}