It makes sense that something like an operating system would be written in C. But how much of it, and what kind of C? I mean, in C, if you needed some heap memory, you would call malloc. But, does an OS even have a heap? As far as I know, malloc asks the operating system for memory and then adds it to a linked list, or binary tree, or so...
On Windows I am loading a DLL and running it. The DLL performs a lot of network activities. Now I need to monitor which url and hosts the DLL connects to. I think using a packet sniffer might be a good option. Can WinPcap be used to capture traffic from a single process? I can't find any such option in the docs.
If that can’t be done us...
Hello People
On left shift of (char) 0xff by 8 and casting it to int we get -256 or 0xffffff00.
Can somebody explain why this should happen?
#include <stdio.h>
int main (void)
{
char c = 0xff;
printf("%d %x\n", (int)(c<<8),(int)(c<<8));
return 0;
}
Output is
-256 ffffff00
...
What is the simplest way to write a timer in C/C++?
Hi,
What is the simplest way to write a timer, say in C/C++? Previously I used a for loop and a do-while loop. I used the for loop as a counter and the do-while loop as a comparison for "end of time". The program worked as I wanted it to, but consumed too much system resources.
I'm l...
Hi
I have some C code that stores ASCII strings in memory as a four byte length followed by the string. The string lengths are in the range 10-250 bytes.
To reduce occupancy I'd like to compress each string individually on the fly, still storing the length (of the compressed string) followed by the compressed string.
I don't want to ...
I have a file named "my file.pdf" and I can't delete this file with this code:
if (remove("/var/tmp/\"my file.pdf\"") != 0)
printf( "Error deleting file\n");
Any suggestion different than do some regex to replace '{whitespace}' for '\{whitespace}'?
...
What patterns have you come across as being used frequently with successful results?
Is there a resource of patterns used in embedded programming?
Most patterns books such as the GOF book focus on OOP techniques, surely there are similar patterns in the embedded systems domain.
...
Hi,
I need to write a simple LDAP client in C. The only binary distributions I found are old and also lack SSL tools needed to implement an SLDAP connection. A complete and up to date distribution that I found is that of Mozilla however it is in source code format and I have not been able to compile it into binary form for windows.
I ...
Hi,
I wanted to call Test1() Method Within WaitAndCallFunc() Function.
Code:
typedef void (*func)();
void StartTimer(void* pFuncAddr);
void WaitAndCallFunc(void* pPtr);
void WaitAndCallFunc(void* pPtr)
{
int i = 0;
int nWaitTime = 3;
while(1)
{
Sleep(1000);
// I want pPtr to call Test1 Function;
if(i =...
Update:
My BAD. The error I am getting is ECONNREFUSED and not EINPROGRESS. After I had checked the %error% variable and found that it is greater than 0, I printfed errno instead of %error%.
Of course errno is EINPROGRESS because it value didn't change since the call to connect().
Question answered. Thanks folks.
I am using the the...
Hi, When I write a C program, I encountered a problem that is as follows:
malloc.c:3074: sYSMALLOc: Assertion
(old_top == (((mbinptr) (((char *)
&((av)->bins[((1) - 1) * 2])) -
__builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0)
|| ((unsigned long) (old_size) >=
(unsigned long)((((__builtin_offsetof
(struct ...
Essentially, what I'm looking for is a function that would allow me to do something like this:
Dumper(some_obj); /* outputs some_objs' data structure */
Thanks.
...
Hello everybody,
I'm not sure if it's a good place to ask such a question.
I'm trying to port some low level library (dbghelp) to wince and I need access to some api that aren't available on wince.
I need to access TEB (Thread Environment Block). There are a couple of API's available on PC that do that, but there is no such thing on WinC...
Hi,
I have a need for a cross-platform (hopefully C) library that can create and mount encrypted filesystem containers. The same functionality of TrueCrypt but as a library so I would not have to externally include and invoke the Truecrypt executables.
Any alternate suggestions or solutions are also very welcome.
Thanks!
...
The Wikipedia entry for the C Preprocessor states:
The language of preprocessor
directives is agnostic to the grammar
of C, so the C preprocessor can also
be used independently to process other
types of files.
How can this be done? Any examples or techniques?
EDIT: Yes, I'm mostly interested in macro processing. Even thoug...
Please pardon the newbie question, my C is very, very rusty.
Trying to build xrunclient from http://www.leftfield.org/~dd/sw.html, on IRIX64, I'm confronted with:
ld32: ERROR: 33 : Unresolved text symbol "XOpenDisplay"
I figure this is because it can't find the proper library, but it finds the header files without complaint. How can I ...
Take a look at these two functions:
void function1() {
int x;
int y;
int z;
int *ret;
}
void function2() {
char buffer1[4];
char buffer2[4];
char buffer3[4];
int *ret;
}
If I break at function1() in gdb, and print the addresses of the variables, I get this:
(gdb) p &x
$1 = (int *) 0xbffff380
(gdb) p...
I'm not sure what is the proper syntax for using C enums. I have the following code:
enum {RANDOM, IMMEDIATE, SEARCH} strategy;
strategy = IMMEDIATE;
But this does not compile, with the following error:
error: conflicting types for ‘strategy’
error: previous declaration of ‘strategy’ was here
What am I doing wrong?
...
I want to read the std output of a system call into a C/C++ string. Can I do this without using a temp file?
Perl
//without file io
$output = `echo hello`;
C++
//with file io
system ("echo hello > tmp");
std::fstream file ("tmp");
std::string s;
file >> s;
...
Possible Duplicate:
Getting the MAC address of the remote host
I'm working on a module which has a client server architecture. And i have to authenticate the connecting peer machine on the basis of Mac address.
At the time of installation i store a encrypted list of valid Mac addresses.
Please note that i have no control...