binary

How to fetch the data from binary log file and insert in our desired table in MySQL?

How to fetch the data from binary log file and insert in our desired table in MySQL? I am on my way of scripting a PHP code for Audit Trail, in this I encountered a situation that if there will be new table created then I will not be available with triggers for that new table and hence no tracking could be done for that, so if I code i...

Homemade fstat to get file size, always return 0 length.

Hello, I am trying to use my own function to get the file size from a file. I'll use this to allocate memory for a data structure to hold the information on the file. The file size function looks like this: long fileSize(FILE *fp){ long start; fflush(fp); rewind(fp); start = ftell(fp); return (fseek(fp, 0L, SEEK_END...

Is there any sense in performing binary AND with a number where all bits are set to 1

Greetings everybody. I have seen examples of such operations for so many times that I begin to think that I am getting something wrong with binary arithmetic. Is there any sense to perform the following: byte value = someAnotherByteValue & 0xFF; I don't really understand this, because it does not change anything anyway. Thanks for hel...

Convert binary information to regular data type without outside modules in python.

Hello World. I'm tasked with reading a poorly formatted binary file and taking in the variables. Although I need to do it in C++ (ROOT, specifically), I've decided to do it in python because python makes sense to me, but my plan is to get it working in python and then tackle re-writing in in C++, so using easy to use python modules won't...

File in binary form

Dear All I want to write data into the file in binary form. I was trying using the mentioned below FILE *fp = fopen("binaryoutput.rgb888", "ab+"); for(int m=0; m<height; m++) { for (int n=0; n< width; n++) { temp = (pOutputImg+m*3+n*3); // here pOutputImg & temp is a pointer to a unsigned...

latest Xemacs for Windows binary download

I'm trying to get an updated version for Windows vista. I previously got 21.4.22 but it's been a year since that release. The linux versions should be 22.x. I'm wondering if anyone else builds stable binaries for Windows ? 21.4.22 has several bugs and I cannot figure out how to fix them. I know Xemacs is not as active as GNU emacs but s...

Versioning friendly, extendible binary file format

In the project I'm currently working on there is a need to save a sizable data structure to disk (edit: think dozens of MB's). Being an optimist, I thought that there must be a standard solution for such a problem; however, up to now I haven't found a solution that satisfies the following requirements: .NET 2.0 support, preferably with...

Split a Large File In C++

Hey all, I'm trying to write a program that takes a large file (of any type) and splits it into many smaller "chunks". I think I have the basic idea down, but for some reason I cannot create a chunk size over 12 kb. I know there are a few solutions on google, etc. but I am more interested in learning what the origin of this limitation ...

C++ string array binary search

string Haystack[] = { "Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Guam", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massa...

is there are nice unix command for dumping the text representation of a binary file.

Hi I got some binary files containing integers. Is there some nice unix command, that will allow me to dump it to a terminal without offset info etc? something like double int[4]; while(fread(tmp,sizeof(int),4,stdin)) for(int i=0;i<4;i++) printf("%d\t",tmp[i]); It seems that hexdump and od gives me the information I want, but t...

Decimal to binary (and vice-versa)

Can anybody give an example of c++ code that can easily convert a decimal value to binary and a binary value to decimal please? ...

Q on Python serialization/deserialization

What chances do I have to instantiate, keep and serialize/deserialize to/from binary data Python classes reflecting this pattern (adopted from RFC 2246 [TLS]): enum { apple, orange } VariantTag; struct { uint16 number; opaque string<0..10>; /* variable length */ } V1; struct { uint32 number; opaqu...

Why use bin2hex when inserting binary data from PHP into MySQL?

I heard a rumor that when inserting binary data (files and such) into MySQL, you should use the bin2hex() function and send it as a HEX-coded value, rather than just use mysql_real_escape_string on the binary string and use that. // That you should do $hex = bin2hex($raw_bin); $sql = "INSERT INTO `table`(`file`) VALUES (X'{$hex}')"; //...

java polymorphic binary search tree

how can i implement a polymorphic binary search tree (that makes use of EmptyTree and NonEmptyTree) without using downcasting or class checking? ...

C# binarysearch a list<T> by a member of T

I have a baseclass Event with a DateTime member TimeStamp. Lots of other event-classes will derive from this. I want to be able to search a list of events fast, so I'd like to use a binary search. (The list-data is sorted on timestamp, but there might be duplicate timestamps for events that occurred simultaneously) So I started out wr...

How to convert PE(Portable Executable) format to ELF in linux

Hi What's the best tool for converting PE binaries to ELF binaries? Following is a brief motivation for this question: Suppose I have a simple C program. I compiled it using gcc for linux(this gives ELF), and using 'i586-mingw32msvc-gcc' for Windows(this gives a PE binary). I want to analyze these two binaries for similarities, using...

Java: what is the class for the isBinary-method?

I am accustomed to java.io.* and java.util.* but not to the tree: com.starbase.util Class FileUtils java.lang.Object | +--com.starbase.util.FileUtils Source. So which class should I import to use the isBinary-method? Do I do "import java.lang.Object;" or "import java.lang.Object.com.starbase.util.FileUtils;"? ...

MATLAB - Delete elements of binary files without loading entire file

This may be a stupid question, but Google and MATLAB documentation have failed me. I have a rather large binary file (>10 GB) that I need to open and delete the last forty million bytes or so. Is there a way to do this without reading the entire file to memory in chunks and printing it out to a new file? It took 6 hours to generate the f...

Why am I not getting the expected results with fread() in C?

Here is my code: #include <stdio.h> int main(void) { FILE *fp; unsigned int i; char bytes[512]; fp = fopen("myFile","r"); for(i = 0;i <= 512;i++) { fread(&bytes, sizeof(bytes), 1, fp); printf("bytes[%d]: %x\n", i, bytes[i]); } } Here is the expected outp...

Binary files printing and desired precision

Hi, I'm printing a variable say z1 which is a 1-D array containing floating point numbers to a text file so that I can import into Matlab or GNUPlot for plotting. I've heard that binary files (.dat) are smaller than .txt files. The definition that I currently use for printing to a .txt file is: void create_out_file(const char *file_nam...