c

How to check login credentials in linux when not running as root?

I have written a cgi-bin application in C that runs in a browser and allows the user to open an interactive shell and view & edit files on a Linux machine. It runs as the standard apache "www-data" user. I just added a login screen to it where the user types in their name and password (in a form) but I cannot authenticate the user using ...

Trying to compile code from OS Dev tutorial

This is a hard question to ask because I'm positive I'm about to be bombarded with haters commenting on "if I can't write an operating system already, I won't ever to be able to write an operating system". Well I've read Modern OS by Tanembaum, Linux Kernel Development, Understanding the Linux kernel and others I still don't know if or n...

How do I make a full screen scrolling messagebox or window?

Hi First let me start of saying I know absolutely nothing about c++ and I am really just more interested in getting this to work then learning c++(I got enough on my plate to learn). So basically I am trying to make a terms of service for my windows mobile 6 professional application but it seems I need to use c++ to do it. After hours ...

#define NULL NULL

#ifndef NULL #define NULL NULL #endif This code compiles in gcc with no warnings/errors. Can someone explain what the preprocessor is doing here? ...

Finding multiple regex hits using approximate matching via the tre library

Using C, I'm trying to find the location and number of matches of a substring within another parent string. Because I also need to include approximate (hamming distance) matches, I'm using the tre library found here: http://laurikari.net/tre/. I'm having trouble understanding some of the documentation on the site, likely because I'm no...

In need of a SOCKS5 server library

I'd like help finding a library that adds SOCKS5 server functionality to my program. Please note, I do not want to connect to a SOCKS proxy server; rather, I want to actually run a SOCKS proxy server within my program. While there appears to be many SOCKS servers, they certainly were not built with the intention of being used as librari...

Can fscanf() read whitespace?

I've already got some code to read a text file using fscanf(), and now I need it modified so that fields that were previously whitespace-free need to allow whitespace. The text file is basically in the form of: title: DATA title: DATA etc... which is basically parsed using fgets(inputLine, 512, inputFile); sscanf(inputLine, ...

Function pointer location not getting passed

I've got some C code I'm targeting for an AVR. The code is being compiled with avr-gcc, basically the gnu compiler with the right backend. What I'm trying to do is create a callback mechanism in one of my event/interrupt driven libraries, but I seem to be having some trouble keeping the value of the function pointer. To start, I have ...

How do I take C programming beyond the console?

I'm trying to learn some graphics programming using C. What would be the best way for a beginner to start? I'd like to how to make programs that use graphics and images that can be run directly from a command line prompt, and don't rely on a windowing system like X to execute. Thanks, Mike ...

Thread-safe timezone-specific time display in C/C++

I have a multi-threaded application which needs to display certain dates to the user. The dates are stored using UTC Unix time values. However, the date must be displayed in the time zone of the user, not the local server time or UTC. Basically, I need a function like this: struct tm *usertime_r(const time_t *timer, struct tm *result, c...

Print an array of numbers from the least significant digit to most significant digit?

8 | * 7 | * 6 | * 5 | * 4 | * * 3 |* * * * * * 2 |* * * * *** ** * * 1 |* * *** ****** **** * * +--------------------------- 012345678901234567890123456 11111111112222222 how would you print numbers from the least significant digits to the most significant digits (like the numbers shown on the x-axis)? Thank you ...

Sending Data at perticular IP in window OS using ANSI C

I want to send data or packets at perticular IP address using ANSI C standard so that my code will be plateform independent, how is it possible in window OS without using window libraries like winsock etc. Kindly give me some guidelines or hints. ...

C for loop indexing: is forward-indexing faster in new CPUs?

Hi all, On a mailing list I'm subscribed to, two fairly knowledgeable (IMO) programmers were discussing some optimized code, and saying something along the lines of: "On the CPUs released 5-8 years ago, it was slightly faster to iterate for loops backwards (e.g. for (int i=x-1; i>=0; i--) {...}) because comparing i to zero is more effi...

what is the difference when the number of threads is determined and undetermined?

Hi, what the difference when the number of threads is determined, as e.g.: for (i*10){ ... pthread_create(&thread[i], NULL, ThreadMain[i], (void *) xxx); ... } and when it is undetermined, just like this: ... pthread_create(&threadID, NULL, ThreadMain, (void *) xxx); ... In my case the numb...

C: Where is union practically used?

I have a example with me where in which the alignment of a type is guaranteed, union max_align . I am looking for a even simpler example in which union is used practically, to explain my friend. ...

Parsing a C header file in Python

Does anyone know a spiffy way to use C header files in Python? For example I have a C program that includes a global variable: typedef struct ImageInfo { uint8_t revisionMajor; uint8_t revisionMinor; uint16_t checksum; } ImageInfo; ImageInfo gImageInfo; /* Placed at a specific address by the linker */ I would like ...

what is the difference between linking and loading in c language

Does linking and loading of the the dynamic libraries both happen at runtime? or is it that only loading of the library happens at run time? ...

Using the return value from scanf in the C programming language as a check

How do you use the return value from scanf to make sure it is a double I've got? double input; do { /* do this as long as it not a double */ printf("Input?"); scanf("%lf", &input); } while(scanf("%lf", &input) != 1); /* this will not work */ ...

Want to know how to write anything on file through program in win32 application

Hello! i am a beginner and want to file handling concept in win32 application for writing anything say text in file which is present in some location on hard disk. Please Reply Thanks in advance... ...

invalid static assert behavior

I am trying to setup a static assert (outside the main function) with GCC v4.3.x: #define STATIC_ASSERT(cond) extern void static_assert(int arg[(cond) ? 1 : -1]) STATIC_ASSERT( (double)1 == (double)1 ); // failed but when I use float numbers, the assert always failed. Is it possible to run this static assert properly ? ...