c

Passing the shell-command to RSH daemon inside an "ACK" packet.

Hello. Writing a program on C, using libnet and libpcap to impersonate an RSH client and inject my own command on the server machine, running RSHD. As I understood, the command should be in the 'payload' of the ACK packet, but in the format, that RSHD will pass it to the shell. How should I assemble the packet to achieve this? ...

Where to split a string literal

Every time I have to split a long string literal into two (or more) pieces, because it does not fit into a single line, I have to decide if I split the text before or after a space. For example: const char * long_text1 = "This is a long text, which does not fit " "in one line"; /* or */ const char * long...

Can you make an incrementing compiler constant?

While sounding nonsensical..... I want a Constant where every time you use it it will increment by 1 int x; int y; x = INCREMENTING_CONSTANT; y = INCREMENTING_CONSTANT; where x == 1; and y == 2 Note I don't want y = INCREMENTING_CONSTANT+1 type solutions. Basically I want to use it as a compile time unique ID ( generally it wou...

NSUInteger vs NSInteger, int vs unsigned, and similar cases

Anyone have the expertise to explain when to use NSUInteger and when to use NSInteger? I had seen Cocoa methods returning NSInteger even in cases where the returned value will always be unsigned. What is the fundamental reason? Is NSInteger or int strictly limited to if we want to represent negative value? From NSObjCRuntime.h: #if _...

Issue on file existence in C

Hi All, Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h> #include<string.h> int main(int argc, char *argv[]) { char *path=NULL; FILE *file = NULL; char *fileSeparator = "/"; size_t size=100; int index ; printf("\nArgument count is = %d", argc); if (argc <= 1...

Accessing structure through pointers [c]

I've got a structure which holds names and ages. I've made a linked-list of these structures, using this as a pointer: aNode *rootA; in my main. Now i send **rootA to a function like so addElement(5,"Drew",&rootA); Because i need to pass rootA by reference so that I can edit it in other functions (in my actual program i have two r...

How to compile C program with multiple files in Xcode

Hi, I am on a Mac running Mac OS X 10.6.3 and Xcode 3.2.1 64-Bit and I was wondering if it was possible to compile a C program with multiple .c files in Xcode. Thanks in advance! ...

Purpose of dereferencing a pointer as a parameter in C.

I recently came along this line of code: CustomData_em_free_block(&em->vdata, &eve->data); And I thought, isn't: a->b just syntactic sugar for: (*a).b With that in mind, this line could be re-written as: CustomData_em_free_block(&(*em).vdata, &(*eve).data); If that's the case, what is the point of passing in &(*a), as a para...

Not able to display the progress bar using threading concept?

I am trying to show a progress bar while my process is going on...in my application there will be a situation where I gotta read files and manipulate them(it will take some time to complete)..want to display a progress bar during this operation..the particular function I am calling is an win 32 ...so if you check my code below ...I am ab...

Problems Using memset and memcpy

So I am trying to create a Memory Management System. In order to do this I have a set amount of space (allocated by malloc) and then I have a function myMalloc which will essentially return a pointer to the space allocated. Since we will then try and free it, we are trying to set a header of the allocated space to be the size of the al...

C question: no warning ???

main() { printf("Hello World."); } Why does no warning is produced in gcc compiler even though we declare main() with return type 'int' ...

for loop in #define

#include <stdio.h> #define UNITS {'*', '#', '%', '!', '+', '$', '=', '-'} #define PrintDigit(c, d) (for (i=0; i < c ; i++)putchar(unit[d]);) char unit[] = UNITS; //void PrintDigit(c, element) { // int i; // for (i=0; i < c ; i++) // putchar(unit[element]); //} int main( ) { int i, element=4; PrintDigit(10, element); ...

BITMAPFILEHEADER equivalent in c/c++?

What is the equavalent of the code below in c/C++? ref BITMAPFILEHEADER bmfh = ref buffer[offset]; //Where buffer is a byte[] array ...

Error in Compiling SIPp with TLS and authentication in Solaris 10 update 5

Hi,, I am trying to compile SIPp with TLS and authentication in Solaris 10 update 5 but when I am trying to bulid it with "gmake ossl" it is giving an error. Already i have installed OpenSSL 1.0.0 gmake OSNAME=uname|sed -e "s/CYGWIN.*/CYGWIN/" MODELNAME=uname -m|sed "s/Power Macintosh/ppc/" OBJ_TLS="auth.o sslinit.o sslthreadsafe.o mi...

dangling pointer, reason for value change after free()?

In the following code segment, after free(x), why does y becomes 0? As per my understanding, the memory in the heap that was being pointed to by x, and is still being pointed by y, hasn't been allocated to someone else, so how can it change to 0? And moreover, I don't think it is free(x) that changed it to 0. Any comments? #include <...

problem in allocating kernel memory by malloc() from user space?

Is there any protection provided by kernel? Because when we tried to allocate memory using an malloc() from user space, the kernel allowed to allocated around 124 MB of memory, and when we try to write into it, the kernel crashed. If there was protection of kernel memory area, this wouldn't have happened ...

how to open many files simultaneously for reading in c

I'm trying to port some of my c++ code into c. I have the following construct class reader{ private: FILE *fp; alot_of_data data;//updated by read_until() method public: reader(const char*filename) read_until(some conditional dependent on the contents of the file, and the arg supplied) } Im then instantiating hundreds of these obj...

Unable to load libsctp.so for non root user

I have a Linux application that uses the libsctp.so library. When I run it as root, it runs fine. But when I run it as an ordinary user, it gives the following error: error while loading shared libraries: libsctp.so.1: cannot open shared object file: No such file or directory But, when I do ldd as ordinary user, it is able to see...

Program visible to Linux as normal directory

I'm trying to write program to work as programmable directory, in other words: User, or other systems open that directory and read/write files or dirs. I try to create program to cache most used files in memory (less I/O to HDD), but right now I don't know how to achive that. There are probably some docs about this but I can't find them....

What does * address(found in printf) mean in assembly?

Disassembling printf doesn't give much info: (gdb) disas printf Dump of assembler code for function printf: 0x00401b38 <printf+0>: jmp *0x405130 0x00401b3e <printf+6>: nop 0x00401b3f <printf+7>: nop End of assembler dump. (gdb) disas 0x405130 Dump of assembler code for function _imp__printf: 0x00405130 <_imp__printf+0>: je ...