c

How do I use waf to build a shared library?

I want to build a shared library using waf as it looks much easier and less cluttered than GNU autotools. I actually have several questions so far related to the wscript I've started to write: VERSION='0.0.1' APPNAME='libmylib' srcdir = '.' blddir = 'build' def set_options(opt): opt.tool_options('compiler_cc') pass def configure(c...

Building files from TCP/IP traffic?

So, for a CS project I'm supposed to sniff a network stream and build files from that stream. For example, if the program is pointed to ~/dumps/tmp/ then the directory structure would be this: ~/dumps/tmp /192.168.0.1/ page1.html page2.html [various resources for pages1 & 2] downloaded file1 /192.168.0...

C macro : turn a number into a string

I have a table that defines symbols appearance on a 5x7 dot display. Something like: extern UINT8 symbols[][5] = { {0x0,0x0,0x0,0x0,0x0}, {0x0,0x0,0x5F,0x0,0x0}, {0x0,0x7,0x0,0x7,0x0}, {0x14,0x7F,0x14,0x7F,0x14}, // etc. The leading part of the table matches ASCII table, followed by a set of special symbols, e.g. an ...

File written by old C code, moved to C#

I'm working on converting an old C program (currently run on UNIX) into our C# system. The program builds some data into several structs and then writes a file using a series of fwrites like this: fwrite ( &loc, sizeof ( struct loc_items ), 1, hdata.fp ); With loc being the data, struct loc_items being the struct it's a type of. M...

How to change the color of a textual cue when sending an EM_SETCUEBANNER Message ?

When you send an EM_SETCUEBANNER message, you get a grey textual cue in your edit control. How to change the color the textualcue in Win32/C ? ...

Estimate Power Consumption Based on Running Time Analysis / Code Size

I've developed and tested a C program on my PC and now I want to give an estimate of the power consumption required for the program to do a single run. I've analysised the running time of the application and of invidiual function calls within the application and I know the code size both in assembly lines, but also raw C lines. How woul...

Handling CGI requests in a bare-bones http server

I am writing a basic http server in C. Handling a simple static .html file is easy but I have no idea how to handle dynamic .pl .cgi file extensions. I know I will have to use exec() but how is my question? ...

How to pass a function pointer to a function with variable arguments?

I don't know how to accomplish this! how to get the function pointer in va_list arguments? thanks so much. ...

cvCanny and float 32 bit (IPL_DEPTH_32F) problem.

I have some problems with OpenCVs cvCanny(...) and the Image data types it can handle. Well, maybe you guys/gals know a solution. I have a 32 bit float image and I want to perform cvCanny on it. The problem is cvCanny can only handle "IPL_DEPTH_8S" or U (signed / unsigned short), or at least that's what I suspect. The OpenCV manual doe...

Visual Basic Cryptography Question

I am trying to mimic the results of some C code that uses the OpenSSL library using the system.security.crytography library in the .net 3.5 world, and I can't seem to get it right. I need some help... part of the issue is my understanding of crytography in general. Here's what is supposed to happen: I send a request for authenticatio...

Creating C macro with ## and __LINE__ (token concatenation with positioning macro)

I want to create a C macro that creates a function with a name based on the line number. I thought I could do something like (the real function would have statements within the braces): #define UNIQUE static void Unique_##__LINE__(void) {} Which I hoped would expand to something like: static void Unique_23(void) {} That doesn't wor...

Reading a line from a socket

I am writing some code in which i need to get a line from a socket whenever the line ends in a newline or carriage return. The line shoould be stored in a buffer. n = recv(sock, &ch, 1, 0); if (n > 0) { if (ch == '\r') { // do stuff } // } // I am using code like this inside a while but it is not working...

Hide console in C system() function, Win.

Hello. I am coding a C program in Dev-C++, and I need to use a couple of Windows (CMD) commands. It is easy, but when the command in the system() function is executed, the program runs the console in the execution. An example: #include <stdio.h> #include <stdlib.h> #include <windows.h> int main() { system("if not exist ...

What happens to a declared, uninitialized variable in C? Does it have a value?

Quick question-- if in C I write: int num; Before I assign anything to num, is the value of num indeterminate? ...

Bit shifting in internet checksums.

This is almost certainly a very silly question, but for some reason I'm having trouble with internet checksum calculations. All of the algorithms basically look something like this: WORD chksm(WORD *startpos, WORD checklen){ ulong sum = 0; WORD answer = 0; while (checklen > 1) { sum += *startpos++; checklen -= 2; } if (checklen == ...

Is IAR assembler possible to import #define from C header to assembler?

Hi All, I have a mixed assembler and C project based on IAR ARM. I have some #define in C header, I like to use (import) them in assembler file. Could anybody tell me it is possible? Many thanks. ...

Verifying that C / C++ signed right shift is arithmetic for a particular compiler ?

According to the C / C++ standard (see this link), the >> operator in C and C++ is not necessarily an arithmetic shift for signed numbers. It is up to the compiler implementation whether 0's (logical) or the sign bit (arithmetic) are shifted in as bits are shifted to the right. Will this code function to ASSERT (fail) at compile time f...

Iterate through a C array

I have an array of structs that I created somewhere in my program. Later, I want to iterate through that, but I don't have the size of the array. How can I iterate through the elements? Or do I need to store the size somewhere? ...

How do I go about Flushing STDIN here?

I have a function (in C) that gets input from the user, (using scanf) stores it in an unsigned int, and returns the input to other functions that handle it: unsigned int input(void) { unsigned int uin; scanf("%u", &uin); return val; } I was wondering, being as I ought to flush stdin, I'd want to use a while loop using get...

emacs, etags and using emacs as an IDE

Hello, My usual tools are Emacs with g++ on a Linux system to implement my research algorithms. For the last some years, I have used emacs in a fairly basic way. I open C or C++ files, edit them with a syntax highlighting scheme of my choice and compile and do other stuff from within emacs (or maybe from a terminal), including using gdb...