c

Is there a way to abort an SQLite call?

I'm using SQLite3 in a Windows application. I have the source code (so-called SQLite amalgamation). Sometimes I have to execute heavy queries. That is, I call sqlite3_step on a prepared statement, and it takes a lot of time to complete (due to the heavy I/O load). I wonder if there's a possibility to abort such a call. I would also be ...

Embedded C function macro problem

Hello, I came across this in embedded hardware using C. #define EnterPWDN(clkcon) ( (void (*)(int))0xc0080e0 ) (clkcon) I have no idea how is this function macro working. I understand clkcon is the function parameter to EnterPWDN, but what is happening after that? ...

Efficiency of boolean comparisons? In C.

I'm writing a loop in C, and I am just wondering on how to optimize it a bit. It's not crucial here as I'm just practicing, but for further knowledge, I'd like to know: In a loop, for example the following snippet: int i = 0; while (i < 10) { printf("%d\n", i); i++; } Does the processor check both (i < 10) and (i == 10) for e...

libxml2 XPATH - Selecting subset of data from XML

Hi guys, I am fairly new to XML dev.. I had a few questions regarding XML parsing with XPATH and libxml. I have an XML structured as : <resultset> <result count=1> <row> <name> He-Man! </name> <home> Greyskull </home> <row> </result> <result count=2> ...

Is there any alternative for printf ?

I have to create a software that must work on several *nix platforms (Linux, AIX, ...). I need to handle internationalization and my translation strings are in the following form: "Hi %1, you are %2." // English "Vous êtes %2, bonjour %1 !" // French Here %1 stand for the name, and %2 for another word. I may change the format, that's...

Calling a function for a period of time

I want to make a call - either a function call or doing some condition for a PERIOD of time ... typically 10 - 20 seconds. I would get some user input for the amount of time and do that ... What is the proper function to use on Linux/Unix systems? gettimeofday seems to be the way to go ... or perhaps time_t time(time_t *t) ... seems...

Segfault instantiating class in custom PHP extension in C

I'm developing my own PHP extension with a class in it. I recently upgraded from Ubuntu 9.04 to 9.10 and the extension broke. I since tried to update to 10.04 to see if it fixes it as my dev environment is 10.04 and it works fine on there. The only major difference from what I can understand is the server is 64 bit and my laptop 32 bit a...

Dumping memory to file

I've got a part of my memory that I want to dump to a file. One reason is to save the information somewhere, and another is to read it again when my program restarts. What is the proper way of doing this? My first thought was: char* start = my_pointer; int i; for (i = 0; i < MEMORY_SIZE; i++) { // write *start to file start++;...

Cannot send character with minicom

Hi all, I'm using minicom to connect through a serial link to a target (UART link of a sparc processor). With gtkterm or cutecom, I can connect, read and send characters. The only issue with them is that they both insert empty lines after each LF character, and : -gtkterm cannot record output to a file -cutecom does not "flush" after r...

Remote system development of C/C++ in Eclipse|Netbeans

Hi all, I am trying to use Eclipse|NetBeans for Remote System Development in Solaris. What I exactly want is: Use these IDE to Build,Debug and CheckIn purpose using Solaris C/C++ compiler and dbx debugger. I want to create the file in solaris from IDE compile and debug in IDE finaly checkIn using IDE. What I have achieved(only in NetBe...

2D array using pointers

I am attempting to read a file with some random names in the format "ADAM","MARK","JESSIE" ..... I have some constraints, the file should be read in a function but should be accessible form the main function with no global variables. The file size and the no of names in the file are not known. This is what I have done till now. I have ...

How can I reserve memory addresses without allocating them.

Hello. I would like (in *nix) to allocate a large, contigious address space, but without consuming resources straight away, i.e. I want to reserve an address range an allocate from it later. Suppose I do foo=malloc(3*1024*1024*1024) to allocate 3G, but on a 1G computer with 1G of swap file. It will fail, right? What I want to do is sa...

Difference between i = ++i and ++i

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) What is the difference between i = ++i; and ++i; where i is an integer with value 10? According to me both do the same job of incrementing i i.e after completion of both the expressions i =11. ...

Windows Registry decryption (CryptUnprotectData) WPA keys

Hi. I am writing a program for linux in C to extract the wpa/wep key from a windows registry hive. Initially I was hoping to use wine's CryptUnprotectData function, but I realise now that wine uses a different algorithm and just mimics window's version. I also realise that only the user that encrypted the data can decrypt it. I am usi...

C language, serial port reader.

hi, I want to make a program that reads a serial port (V.24). with the info from the serial port i need to split a string up. and add it to an mysql database. I don't know C very well, so i need some help with what functions should i use. The program has to run under windows xp, and i have to make it an service. thanks, Sebastian ...

Warning-free Templating in C

Transitioning from C++, I am now learning the dark art of C and have developed the following code to replace my need for templating. In the bottom example, I have implemented your garden-variety Node structure in such a way that it can be used to store any data type. Consider the following... // vptr.c #include <stdio.h> struct Node {...

Standard library tags

I use tag files for code completion and for a quick, inline view of parameters, overloads, files (where declared), etc. Where can I find freely available tags for the C99, C++03, and C++0x standard libraries? (C89 would be better than nothing, but I'd rather have C99.) I prefer tags without cruft; e.g. implementations use reserved nam...

Recalculation of Balance Factor in AVL Tree

After performing a rotation to balance an AVL tree, immediately after an insertion, how can I change the balance factor of all the parent nodes (appropriately, by -1 or 1)? Each node of the AVL tree has the following structure: typedef struct _avlTree { nutbolt part; int balanceFactor; struct _avlTree *left,*right; } *avlTree; I h...

Evaluation of C expression

int main() { int i = -3, j = 2, k = 0, m; m = ++i || ++j && ++k; printf("%d %d %d %d\n", i, j, k, m); return 0; } i thought that && has more precedence that || as per this logic ++j should execute, but it never does and the program outputs -2 2 0 1. What is going on here? What are the intermediate steps? ...

Whats wrong with the following code?

#include<stdio.h> #include<ctype.h> int main() { FILE *fpin = fopen("in.txt", "r"); fprintf(fpin, "hello, world!"); fclose (fpin); char c; fpin = fopen("in.txt", "r"); FILE *fpout = fopen("out.txt", "w"); while ((c = fgetc(fpin)) != EOF) { fputc (toupper(c), fpout); } fclose (fpout); fc...