c

RC2 decryption using CCCrypt

I'm trying to decrypt RC2 data with only 64 effective bits. Since I can only have 64-bits, it's my understanding that before calling CCCrypt I must use a method to reduce the key down to this many bits. Since I couldn't find any such method in Apple's CommonCrypto library, I am using this keyschedule method I found. These are the metho...

How to disable GTK Drag'n Drop ?

How to complete disable Drag'n Drop from a GtkEntry ? ...

How do I code a simple integer circular buffer in C/C++?

I see a lot of templates and complicated data structures for implementing a circular buffer. How do I code a simple integer circular buffer for 5 numbers? I'm thinking in C is the most straightforward? Thanks. ...

How to set a time limit on a function with a secure area

Hi, I'm trying to develop a program to time limit the execution of a function. In the code below I have a function named Inc which does a lot of iterations (simulated by the infinite loop). The first part of each iteration is quite long, followed by a second part that should be pretty fast. I don't mind preempting the execution while i...

How does modulus of a smaller dividend and larger divisor work?

7 % 3 = 1 (remainder 1) how does 3 % 7 (remainder ?) work? ...

What dynamic programming features of Perl should I be using?

I am pretty new to scipting languages (Perl in particular), and most of the code I write is an unconscious effort to convert C code to Perl. Reading about Perl, one of the things that is often mentioned as the biggest difference is that Perl is a dynamic language. So, it can do stuff at runtime that the other languages (static ones) ...

Custom malloc for lots of small, fixed size blocks?

I need to allocate, and free lots of fixed size, small (16 byte) blocks of memory, in no fixed order. I could just call malloc and free for each, but that will probably be very inefficient. A better solution probably would be to call malloc and free for larger blocks, and handle the allocation within those blocks itself. The question ...

trying to pass from hex(base 16) to dec to ip6 /proc/net/tcp6

Hi, im reading the content of the file /proc/net/tcp6 and trying to transform that notation of ip6 into a '0::1' like previously with ipv4 y use the next method. struct sockaddr_in tmp_ip; char ip_str[30]; char ipex[]='00000AF0'; /*read from the file /proc/net/tcp */ tmp_ip.sin_addr.s_addr=(int)strtoll(ipex,NULL,16); inet_ntop(AF_IN...

some character delete with fwrite

I'm trying to replce some letter with the below code. But, the result shows "ANULL" not "A"... How can I remove the NULL space... ps. I'm modifying binary file information. char *pos = NULL; if(NULL != (posFind = strstr(fp, "AB"); strncpy(&fp->base[0], "A", 2); if(_fseek64(fp, 0, SEEK_SET)!= 0) return ZD_ERROR_IO_FAILED; fwrite(&f...

Reverse iteration with an unsigned loop variable

Hi all, I've been discussing the use of size_t with colleagues. One issue that has come up is loops that decrement the loop variable until it reaches zero. Consider the following code: for (size_t i = n-1; i >= 0; --i) { ... } This causes an infinite loop due to unsigned integer wrap-around. What do you do in this case? It seems ...

Argument list too long. Building Hubbub HTML Parsing Library. execv

When I attempt to build this library on my system (Fedora) Linux localhost.localdomain 2.6.33.8-149.fc13.i686 #1 SMP Tue Aug 17 22:45:56 UTC 2010 i686 i686 i386 GNU/Linux I get a long list of errors of which this is the last few lines: build/makefiles/Makefile.top:542: warning: overriding commands for target `build-Linux-Linux-releas...

C: Common Frameworks/Libraries

What are some common general purpose library as Boost is to C++ but for C? It should be a cross-platform library and include collections such as trees, linked-lists, queues, etc... What are the advantages/disadvantages to those libraries? ...

How do you get info for an arbitrary time zone in Windows?

Ideally, what I'd like to be able to do is take the name of a time zone and ask Windows for its corresponding time zone info (offset from UTC, DST offset, dates for DST switch, etc.). It looks like Windows uses a TIME_ZONE_INFORMATION struct to hold this sort of info. So, presumably, I want a function which takes a string with the time z...

Any tips for dealing with a very small stack?

I was wondering if any developers in the embedded space know of any interesting tricks to help lessen the pain of developing for microcontrollers with very limited stack space. I've recently been writing some firmware for 8-bit uCs (Microchip PIC18F family, 31 byte stack) and as a consequence I have had to flatten my programs and reduce...

zip file encryption

I'm trying to block zip file open... How to block it.... Is there any other methods except modifying zip header info. My rosources are packed with zip file but I don't want to open it to users... Please let me know it ...

P2P programing in C - Trying to implement a Bittorent Client using C

Hello, Network Programming classes have begun for us in the college and I too have been giving it a lot of reading for the past one month. Now, when I have understood the OSI and other reference models including how various protocols like FTTP, HTTP, POP3, P2P etc works; I would like to apply my theoretical knowledge into practise. S...

How to handle unicode character sequences in C/C++ ?

What are the more portable and clean ways to handle unicode character sequences in C and C++ ? Moreover, how to: -Read unicode strings -Convert unicode strings to ASCII to save some bytes (if the user only inputs ASCII) -Print unicode strings Should I use the environment too ? I've read about LC_CTYPE for example, should I care abou...

Why does popen() only work once?

Hi all, When I run the program below on my Mac (OS/X 10.6.4), I get the following output: $ ./a.out Read 66 lines of output from /bin/ps Read 0 lines of output from /bin/ps Read 0 lines of output from /bin/ps Read 0 lines of output from /bin/ps Read 0 lines of output from /bin/ps Why is it that popen() only reads data the first time...

If-else block and unexpected results with float datatype. [Edited with one more question]

Hello, I compiled the following program with gcc 4.4.1 and I get unexpected output (Well, unexpected for me) #include<stdio.h> int main() { float x=0.3, y=0.7; if(x==0.3) { if(y==0.7) printf("Y\n\n"); else printf("X\n\n"); }...

what is the meaning of == sign ?

Hi, I am trying to figure out what == sign means in this program? int main() { int x = 2, y = 6, z = 6; x = y == z; printf("%d", x); } ...