c

How do I create a new thread to make pcap_loop() and gtk_main() compatible?

These two functions are both infinite loops, and the programe hangs once called in the same thread. gtk_main(); ... pcap_loop(adhandle, 0, packet_handler, NULL); When I click the "start" button,I want pcap to start working;And if I press the "stop" button,pcap stop. How do I create a child thread and run pcap_loop(adhandle, 0, pack...

Graph of included files

When I work on someone else's code, I tipically need to abuse of grep in order to find data types declarations etc, and this usually makes me confused. I'd like to have some tool which analyzes the source code and produces some graphviz-like drawing and allows me to follow dependencies. Also I've found this on the internet, but I think...

About using assembly with c

Hi. I've sort of just finished a mandatory task at school, and I'm about to deliver it. But then I came across something that was unfamiliar, header files. :( What I've got: test-program.c task_header.h function1.s function2.s function3.s function4.s test-program.c: #include <stdio.h> #include <stdlib.h> #include <string.h> #incl...

gcc does not resolve extern global variables, with or without -c option

Hello everyone! So i have this issue : i am declaring some extern global variables in my C program. If I don't use the -c option for gcc, i get undefined references errors. But with that -c option, the linking is not done, which means that i don't have an executable generated. So how do I solve this? Here is my makefile (written thanks...

Simple dynamic memory allocation bug.

I'm sure you (pros) can identify the bug's' in my code, I also would appreciate any other comments on my code. BTW, the code crashes after I run it. #include <stdlib.h> #include <stdio.h> #include <stdbool.h> typedef struct { int x; int y; } Location; typedef struct { bool walkable; unsigned char walked; // number of...

When can argv[0] have null ?

What I have understand about passing arguments to main() from command line is that argc has a minimum value of 1 and argv[0] will always have the program name with its path in it. If arguments are provided at the command line, then argc will have a value greater than one and argv1 to argv[argc-1] will have those arguments. Now a paragr...

How do I merge zlib1.dll into my executable in C?

My executable needs zlib1.dll to run, and I need to keep them together now and then. How can I merge it into the executable to save the trouble? I'm using cmake to build the executable. UPDATE zlib1.dll is not directly included by my programe,but required by libpng14-14.dll(one dll of the gtk bundle) ...

system() to c# without calling cmd.exe

how to translate system("") to C# without calling cmd.exe? edit: i need to throw something like "dir" ...

interpreting assembly instructions

I am trying to translate the following: Action: pushl %ebp movl %esp, %eax subl $0x32, %esp movl $0x0, -0x8(%eax) movl $0x0, -0x4(%eax) movl -0x4(%eax), %eax cmpl $0x32(%eax), %ebp movl -0x4(%ebp), %eax sall $0x2, %ebp addl 0x8(%ebp), %ebp movl (%ebp), %ebp addl %ebp, -0x8(%eax) addl $0x1, -0x4(%eax) What is the best way ...

callback pattern

Hello, gcc 4.4.3 c89 I am creating a client server application and I will need to implement some callback functions. However, I am not too experienced in callbacks. And I am wondering if anyone knowns some good reference material to follow when designing callbacks. Is there any design patterns that are used for c. I did look at some p...

Writing a DLNA server (DMS) in Cocoa/Objective-C/C

I'd like to write a DLNA server in Cocoa for the Mac. Are there any libraries for speaking UPnP/DLNA in Objective-C or C? Failing that, where is the spec for DLNA so I can write my own? ...

get text from running application window (osx)

Hi, I'm very very new to OSX/UNIX and i was wondering how i would go about getting a certain text from a application window. Explanation: App1 is running, it has a textfield with changing data. I start app2 and i want the data in the textfield from app1 available in app2. (i did not write app1 its a commercial app) I guess it should p...

How to get smartcard reader name in Windows 7 using C# or C/C++?

Hi! I'm trying to make a C# program which will use a C .dll (unfortunately, the .dll doesn't have good documentation) to access a smart card. One of the functions of the .dll uses name of the reader as argument. My problem is that I don't know how to get the name. After looking for answers I found something similar to what I need in an...

how to add a function to that program, and call that function from the command line in the function

I have to add a custom function which shows currently running foreground and background processes launched by this shell. How do I define and call that function from the shell's command line? a#include "smallsh.h" /*include file for example*/ /*program buffers and work pointers*/ static char inpbuf[MAXBUF], tokbuf[2*MAXBUF], *ptr ...

Easy framework for OpenGL Shaders in C/C++

I just wanted to try out some shaders on a flat image. Turns out that writing a C program, which just takes a picture as a texture and applies, let's say a gaussian blur, as a fragment shader on it is not that easy: You have to initialize OpenGL which are like 100 lines of code, then understanding the GLBuffers, etc.. Also to communicate...

OpenGL game written in C with a Cocoa front-end I want to port to Windows

Hello, I'm wondering if someone could offer me some tips on how to go about this. I have a MacOS X OpenGL game that is written in very portable C with the exception of the non-game-play GUI. So in Cocoa I set up the window and OpenGL context, manage preferences, registration, listen for keystrokes etc. But all of the drawing and proce...

How to prevent users from typing incorrect inputs ?

Hello, This program asks for any row number. I want the program to loop a scan function if the user types anything else other than numbers.. My code is : do{ printf("Enter row number\n"); scanf("%d",&row); }while(row>='a' && row<='z'); but this code doesnt work .. I keep getting an error when typing in a letter. I tried man...

How do you parse the XDG/gnome/kde menu/desktop item structure in c++??

I would like to parse the menu structure for Gnome Panels (the standard Gnome Desktop application launcher) and it's KDE equivalent using c/c++ function calls. That is, I'd like a list of what the base menu categories and submenu are installed in a given machine. I would like to do with using fairly simple c/c++ function calls (with NO s...

Enter custom file name to be read ?

Hello, I want to allow users to type the name of any .txt file to be read/written. This is my code : printf("Enter .txt file name\n"); scanf("%s",&fname); FILE *inputf; inputf=fopen(&fname,"w"); Problem is this method does not work (having &fname) as a parameter. I can imagine its because C needs "filename.txt" for it work...

One-liner to determine who wins in Rock, Paper, Scissors

So I am writing a simple Rock, Paper, Scissors game in C (it's for an assignment by the way, though the main thing is to learn sockets. Also, I suspect it will be due before I get a good answer). I have it setup as Rock=0, Paper=1, and Scissors=2. Is there an easy one-liner to determine who wins? I tried playing around with it on pap...