c

force a new address space for a function (make static variables unstatic)

I got a function in a file that works for a single function call. But since it depends on alot of static declarations within this file (I didn't make this file, and its to big to modify). It wont work with multiple function calls. Is there some way to make each function call unaware of previous calls, or current calls? In effect force a...

C - scanf() vs gets() vs fgets()

So I've been doing a fairly easy program of converting a string of Characters (assuming numbers are entered) to an Integer. After I was done, I noticed some very peculiar "bugs" that I can't answer. Mostly because of my limited knowledge on how these 3 functions in Thread title works (I did read a lot of literature though). So without ...

Is it reasonable to write a server application in C# in my case?

I want it to work on windows servers. It will be a cloud type server - it'll consist of modules\parts running on different machines all over the world using http\tcp + upnp to connect to each other There are going to be controlling\monitoring\observing modules on each machine to provide stats on performance This net is going to be worki...

C: save received Winsock packet to file as hex

I need to do what most packet monitoring programs do (Wireshark, tcpdump, etc.). When data is received through Winsock, I just need to convert the packet to a hex representation and save it to file. The data is just a simple char array. I've tried lots of things like sprintf but with no luck. I also don't want to use itoa since it's no...

Program overflows call stack by sheer force of will

Here's the call stack from a user's crash report: Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 com.growl.GrowlSafari 0x179d383c writeWithFormat + 25 1 com.growl.GrowlSafari 0x179d388e writeWithFormat + 107 2 com.growl.GrowlSafari 0x179d388e writeWithFormat + 107 3 com.growl.GrowlSafari...

Performance difference between gcc and g++ for C program

Lets say i have written a program in C and compiled it with both gcc and g++, which compilation will run faster? gcc or g++? I think g++ compilation will make it slow, but not sure about it. Let me clarify my question again because of confutation about gcc. Let say i compile program a.c like this on console. gcc a.c g++ a.c which a...

obtain the current username using WMI

I am using Win32_NetworkLoginProfile or Win32_Account to get a list of the users for a system. Call to these objects return a lot of users, some local and some belonging to a domain (if the system is part of a domain). Is there a way to obtain the current user name using WMI? If yes, how? furthermore, using Win32_Account I can check wh...

Nginx proxy module and socket descriptor passing

I'm implementing a server passing socket descriptors to worker processes for handling. It send them via UNIX sockets using the sendmsg system call. Server itself can listen on a UNIX socket or an INET socket. I have a problem putting it behind nginx. When my server runs on a INET socket, everything is OK. But proxing doesn't work through...

Building a C DLL compatible with Dreamweaver.

The documentation I am referencing is here, and is fairly short and to the point: http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/help.html?content=dwr_sourcecontrol_so_01.html The problem I am running into is that I am not sure how to compile the actual DLL. The last reply on the adobe extension forums is 3 months old, and I am not...

Test for directory existence in C

I have a function that should create a directory. I want to test to make sure that the directory is created, and has the correct permissions I can't use lstat since I get EPERM when I do so (I assume I'm not supposed to know that much about a directory). So what else should I use? I can try to open it it with opendir, but that doe...

Saving stack by directly writing into the send buffer below

Imaging having a stack of protocols and some c/cpp code that neatly covers sending on each layer. Each send function uses the layer below to add another header until the whole message is eventually placed into a continuous global buffer on layer 0: void SendLayer2(void * payload, unsigned int payload_length) { Layer2Header header; ...

Convert SSL private key to a string

From pkcs12 file, I extracted the private key and cert using the following - PKCS12_parse(p12, argv[2], &privatekey, &cert, &ca); Now, I need to use the privatekey and cert to sign an XML using xmlsec libraries. However, xmlSecCryptoAppKeyLoad() expects the key in const char* format. How do I do the conversion? Or, can I use xmlSecC...

Detecting connection to a domain

I'm trying to detect either by calling an API or using WMI whether a computer is connected to a domain. I am currently reading the env. variable USERDOMAIN to check whether I am connected to a domain or not but that only works for domains that I know. Is there a better way to see whether I am connected to a LAN/domain? The code is in ...

String literals vs const char* in C

Why don't ANSI C compilers flag the use of a string literal argument in a function call in which the correponding parameter does not have a const qualifier? For example, the following code could generate an exception by trying to write to read only memory. void somefunc(char buffer[10]); void somefunc(char buffer[10]) { int i; ...

volatile variables as argument to function

Having this code: typedef volatile int COUNT; COUNT functionOne( COUNT *number ); int functionTwo( int *number ); I can't get rid of some warnings.. I get this warning 1 at functionOne prototype [Warning] type qualifiers ignored on function return type and I get this warning 2, wherever I call functionTwo with a COU...

Displaying data using BIOS in C

Is there any way to print data using bios in c. I know in assembly you can use int 0x10, but is there any equivalent for C? ...

Simple C program to Count Character - Help please.

Hey, so I've wrote two programs in C to count characters and print the value but neither seem to work. One uses the while loop and the other uses for, no errors are reported while compiling, but neither print the total count. Or anything for that matter. Here's the code using while: #include <stdio.h> /* count characters and input usi...

gdb unable to break on lstat call

Hello all, I'm debugging PHP 5.2.9 and everything works fine, but today during debugging I see that gdb don't stop when I set: (gdb) break lstat the breakpoint is in the list (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x00002aaaaf810ea0 but, as written before, ...

Finding consecutive bit string of 1 or 0

How to find the length of the longest consecutive bit string(either 1 or 0)? 00000000 11110000 00000000 00000000 -> If it is 0 then length will be 20 11111111 11110000 11110111 11111111 -> If it is 1 then length will be 12 ...

What's the C escape sequence for blanks?

I'm writing a program to count blanks, tabs, and newlines. I remember what the escape sequence for tabs and newlines are, but what about blanks? \b? Or is that backspace? ...