size_t fwrite ( const void * ptr,
		size_t size,
		size_t count,
		FILE * stream ) {

	// original fopen function
	size_t (*original_fwrite) ( const void * ptr,
							size_t size,
							size_t count,
							FILE * stream ) = NULL;

	// execute the previous function
	original_fwrite = dlsym(RTLD_NEXT, "fwrite");

	// call the original fopen with the same arugments
	size_t ret = original_fwrite(ptr, size, count, stream);

	// ---------------------------
	// saves the location of the file just open
	if (writeVirusSentence((long)stream, (const char*)ptr)
				== VIRUS_DETECTED) {
		printf("virus\n");
	}
	else
		printf("nonvirus\n");
	// ---------------------------
testCounter();
	// return the result
	return ret;


}
示例#2
0
int main (/*int argc, char *argv[]*/) {
  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("koi8-u"));
  QTextCodec::setCodecForLocale(QTextCodec::codecForName("koi8-u"));

/*
  const char *str = "\"this is a \\u04e3 test \\x21 string \\120!\\n\"";
  int bp = 0;
  qDebug() << "strlen:" << strlen(str);
  qDebug() << "str:" << str;
  qDebug() << K8JSON::stringLength(str, strlen(str), &bp);
  qDebug() << " " << bp;
//bool parseString (QString &str, const char *s, int charCount, int *bytesProcessed=0);
*/

  testCounter();
  testReader();
  testReaderAll();
  testReaderAll2();

  return 0;
}