c

calling a callback from a thread using function pointers

Hello, c program compiler gcc I have 3 files. main.c stop_watch.h and stop_watch.c This program does work. I call start_stopwatch. And it will callback in main.c timeout_cb() after the time has expired. I also run this in a seperate thread, as I don't want to block in main, as I will have other code I need to run. 1) The seconds in g...

Vector Array

I am suppose to create a vector array in C to use in my project. I have not worked with such data structure before, and can't seem to find good information on it. Can you provide a link to information or post the information which describes this data structure in regard to its usage, benefits, and the functions it has. An implementatio...

some console GUI questions

For the following questions, answers may be for C/C++, C#, or Python. i would like the answers to be cross platform if possible but i realize i will probably need conio or ncurses how do i output colored text? how would i do a GUI like top or nethack where certain things are "drawn" to certain spaces in the terminal? if possible a ...

self referential struct definition?

Hi I haven't been writing C for very long, and so I'm not sure about how I should go about doing these sorts of recursive things... I would like each cell to contain another cell, but I get an error along the lines of "field 'child' has incomplete type". What's up? typedef struct Cell { int isParent; Cell child; } Cell; Thanks, ...

Are conflicting types always a problem in C?

I am having growing pains moving from Java to C. I have become used to having different methods with the same name, but which take different parameters. In C this creates problems? Cell makeCell(int dim, int iterations, Cell parent); Cell makeCell(Cell parent); Is there some quick little work around for this problem, or should I just...

What is the correct way to declare and use a FILE * pointer in C/C++?

What is the correct way to declare and use a FILE * pointer in C/C++? Should it be declared global or local? Can somebody show a good example? ...

C code for ps command

Can you help to develop ps command of Linux in C language? Or is there any reference site which can help me? ...

Detect RPC connection loss from server-side on Windows

Is there any way to check the status of the RPC connection from the server-side? I am looking for a way to detect if the connection from the client is lost, be it client crash or other connectivity issues. ...

How to Log Stack Frames with Windows x64

I am using Stackdumps with Win32, to write all return adresses into my logfile. I match these with a mapfile later on (see my article [Post Mortem Debugging][1]). EDIT:: Problem solved - see my own answer below. With Windows x64 i do not find a reliable way to write only the return adresses into the logfile. I tried several ways: Tri...

strftime( ) doesn't display the seconds correctly

I tried strftime( ) to get a formatted time-stamp. char ft[ 256 ]; struct tm *tmp; strftime( ft, 256, "%D - %T", tmp ); My problem is that I get "13/02/60 - 03:07:-17958194" as a result. Is there a way to display the seconds properly? (I'm using Mac OS X and gcc) ...

segmentation fault on Unix - possible stack corruption

hello, i'm looking at a core from a process running in Unix. Usually I can work my around and root into the backtrace to try identify a memory issue. In this case, I'm not sure how to proceed. Firstly the backtrace only gives 3 frames where I would expect alot more. For those frames, all the function parameters presented appears to co...

How do I call an ORACLE function from OCI ?

I can call an ORACLE stored procedure through OCI in a C program by constructing the SQL command for the command, here's a brief snippet from my code: /* build sql statement calling stored procedure */ strcpy ( sql_stmt, "call get_tab_info(:x)" ); rc = OCIStmtPrepare(p_sql, p_err, sql_stmt, (ub4) strlen (sql_...

Securing EEPROM data against modification

Generally I would go about this by placing something(s) unique and random in the ROM image and use that as a seed to encrypt the EEPROM content to stop extraction and reprogram after image mod. An obvious flaw seems to be that this doesn't stop tampering in the form of replacing the EEPROM external chip with a blank one... oh look were ...

MSP 430 Code problem

I'm developing pressure measuring device. I've used MSP430F133 chip and using IAR embedded workbench. It shows pressure in 3 diff units. I'm taking 32 samples and averaging it. Unit selection on P5, according to the unit selected output value is calculated and displayed on LCD. now a unit "IN WC" is showing binary averaged vale of inp...

Fast way to determine if a PID exists on (Windows)?

I realize "fast" is a bit subjective so I'll explain with some context. I'm working on a Python module called psutil for reading process information in a cross-platform way. One of the functions is a pid_exists(pid) function for determining if a PID is in the current process list. Right now I'm doing this the obvious way, using EnumProc...

Fast server side image generation library?

For a web project I need the possibility to generate jpg and animated gif images very fast. As server platform I will use Linux and the NekoVM (behind a apache via mod_tora). As there is no library for image generation for haXe and neko I am about to write a own one. Neko itself is written in c, and you can simply extend the VM writing ...

XML APIs in C?

Are they all this complex? : http://msdn.microsoft.com/en-us/library/ms766497(VS.85).aspx Just need something basic to produce XML in C. ...

Breaking ReadFile() blocking - Named Pipe (Windows API)

To simplify, this is a situation where a NamedPipe SERVER is waiting for a NamedPipe CLIENT to write to the pipe (using WriteFile()) The Windows API that is blocking is ReadFile() The Server has created the synchronous pipe (no overlapped I/O) with blocking enabled The client has connected, and now the server is waiting for some data....

Run application continuously

Whats the smartest way to run an application continuously so that it doesn't exit after it hits the bottom? Instead it starts again from the top of main and only exits when commanded. (This is in C) ...

How to test a static function

As applying unit-test to some C code, we run into a problem that some static function can not be called at the test file, without modifying the source code. Is there any simple or reasonable way to overcome this problem? ...