Thursday, July 28, 2011

How to Real-time Scan with Clamwin

Clamwin is a free and open source Anti-virus for Windows -- thus the suffix "win". This means that the community provides the developers tons and tons of possible virus infected files thus making Clamwin more efficient in tracking new virus than any other proprietary anti-virus. But there's a catch.

With its large database of virus definitions, Clamwin cannot do a real-time or active scan of your computer. It will not detect a virus-infected file from being copied to and from your computer. Although it does offer a scheduled scan, we know that a real-time scan if far safer.

As quoted from Clamwin's homepage,
Please note that ClamWin Free Antivirus does not include an on-access real-time scanner. You need to manually scan a file in order to detect a virus or spyware.

So how do you make a real-time scan with Clamwin? First, download and install Clamwin if you haven't done already.

Next, download and install complimentary free and open source software called Clam Sentinel.

Clam Sentinel detects file system changes like when some unauthorized program copy, or modify a file. Each file being accesed is thrown to Clamwin to do some virus-checking. This is a good thing if you want to keep your computer safe from unwanted virus. The down side however is that you computer will run slower each time you launch an application, copy files, and such. But this would not be a problem if you are already used to Norton's behavior.

Sunday, March 20, 2011

GCC: G++ ifstream reads extra unwanted characters

Been having trouble with GCC's G++ 4.5.2 with MinGW on Windows. I kept having unwanted characters from a file, which should not be present in the first place.

Given that I have a hello.txt text file that contains,
Hello World
Hello Universe

when opened with Notepad or any other text editor, G++ keeps sending me,
Hello World
Hello Universe

Of course, "zpzksmsm3jk4509s" is just a representation of the garbage data I'm getting. Most of the time, that garbage data is readable. So I usually get something like,
Hello World
Hello Universe

So there is basically no way for me to know which is a garbage data and which is still part of the file. Somehow, getting the file size doesn't seem to work correctly.

string loadFile(string p_fileName) {
  const char *l_fileName = p_fileName.c_str();
  char *bufPath = new char[strlen(l_fileName)];

  ifstream file(bufPath, ios::in|ios::ate);
  ifstream::pos_type size;
  char * memblock;
  string ret;

  size = file.tellg();
  memblock = new char [size];

  file.seekg (0, ios::beg); (memblock, size);

  ret = memblock;
  delete []memblock;
  delete []bufPath;

  return ret;

Just so you could follow me further, I am trying to make a simple interpreter. I am barely at the part where I have to tokenize the text content and just had a basic checking of which is a command and which is not.

As I run my interpreter, I get the "expected" error, "Unknown command ` zpzksmsm3jk4509s'". But it's the "zpzksmsm3jk4509s"-part of the message that I was not expecting. As I said, the text file only contains nothing more but
Hello World
Hello Universe

It took me a couple of days before finally figuring out the problem.

According to a Cygwin FAQ entry, there seem to be an abnormality with Windows dealing with CR/LF.

From a Notepad's perspective, the hello.txt file is only 32bytes long. That counts Hello World (11 bytes), and (3 bytes), Hello Universe (14), plus two instance of CR and LF (thus, 4bytes).

G++ on Windows, on the other hand, also sees 32bytes. But! As what the Cygwin FAQ page says, it seems, Windows gives you CR and LF as one single character. Meaning, you, as the coder, should only read 30bytes long. That's why G++ is giving me extra He content.

So I had to modify my loadFile from reading the content all at once, into reading the content one character after the other. Then upon reading an 'LF', I will try to check if 'CR' was the previous character, giving me a CR/LF. In which, I will have to lessen my expected length in each instance of a CR/LF.

My code looked sort of something like this.
  int i = 0;
  file.seekg (0, ios::beg);
  while (file.eof() == false) {
    memblock[i] = (char) file.get();
    if (memblock[i] == '\n') {
      if (i > 0 && memblock[i-1] == '\r') {
        memblock[i-1] = '\n';

Then make sure the last character of memblock would be a string-terminating "\0" since memblock is not a C++ String but a char*.

Now, if you ask, why did you get a CR then LF if Windows only gives you CR/LF as single character? Well, it seems, if you will have to read the file one character after the other, CR won't be CR/LF but simply CR. Making the next simply LF. You could assume that it's more of a G++ problem than a Windows problem. But as the Cygwin FAQ page suggests, it is a Windows file-handling problem.

Saturday, February 19, 2011

What the hell happened to facebook?

Facebook redirects to Myspace. What in the world happened to Facebook?

Good thing somehow. So I am forced not waste more time on any of those addictive yet lame Casual Games.


(/me goes back programming. :D)


I guess you came here to look for answer. Well... it's just a problem with re-routing, which usually occurs on servers -- not Facebook server but Content Delivery Network servers and/or your router device. What happens is that, if there was a problem fetching for the address of a site you are trying to visit (in this case,, your router will try to provide you alternative site that is just about the same as to what you wanted to view (in this case,

So how do you go about this? You can simply restart your router. Or wait for a couple more minutes. Make sure you hard refresh your browser (do this by pressing Ctrl+F5), or clean you browser's cache.

But then again, if I were you, I would attend to something more important than wasting more time on Facebook. :)

Saturday, February 12, 2011

MSYS pr not found

Ever got the pr not found error on MSYS?

Not sure why the packages made pr command to be obsolete. But compiling FFMPEG on Windows using MinGW and MSYS requires pr in the toolchain.

Do not worry, it is still on MinGW's download page though not easily accessible. It's hidden inside MSYS/BaseSystem/msys-core/obsolete

But be careful, you will only need the PR.EXE, everything else is unnecessary.

UPDATE: Updated link.

Tuesday, January 11, 2011

Open source Matroska MKV converter

It's been a long time since I blogged about anything.

Is your hard drive (the one where you save you files and all that -- not the other one, if you know what I mean ^^) getting all spaced up because of your video file collections? Despite the number of hard disks in your PC?

Don't sway there's an open source MKV converter that will take care of your AVIs.

As of this post there's simply no better compressed video format than Matroska. Sad as it may be, but MKV is not an open format.

Enter HandBrake, an open source (GPL-licensed) multiplatform video converter available for Mac OS X, GNU/Linux and Windows.

Remember. I'm just showing you a tool to help you get more disk space. I am not telling you to download pirated Hi-Def DVD rips out in the Internet and have the file size get shrank by this tool. Also, what I just said is not a reverse psychology thingy. ;)

EDIT: Been using MKV for more than a year and I never had the slightest idea that MKV was indeed an open format. Thanks robux4!