Friday, February 29, 2008

Life is beautiful!!! Live it !!!

A Nice Article from the writings of Swami Vivekananda...............

I once had a friend who grew to be very close to me. Once when we were
sitting at the edge of a swimming pool, she filled the palm of her hand
with some water and held it before me, and said this: "You see this water
carefully contained on my hand? It symbolizes Love."

This was how I saw it: As long as you keep your hand caringly open and
allow it to remain there, it will always be there. However, if you attempt to
close your fingers round it and try to posses it, it will spill through the
first cracks it finds.

This is the greatest mistake that people do when they meet love...they try
to posses it, they demand, they expect... and just like the water
spilling out of your hand, love will retrieve from you . For love is meant
to be free, you cannot change its nature. If there are people you love,
allow them to be free beings.

Give and don't expect.
Advise, but don't order.
Ask, but never demand.

It might sound simple, but it is a lesson that may take a lifetime to
truly practice. It is the secret to true love. To truly practice it, you must
sincerely feel no expectations from those who you love, and yet an
unconditional caring."

Passing thought... Life is not measured by the number of breaths we take;
but by the moments that take our breath away.....

Life is beautiful!!! Live it !!!

Thursday, February 28, 2008

Transaction Control

You can use two methods to specify the boundaries of transactions with SQL statements. In the most common method,
you specify the start of a multistatement transaction by executing the BEGIN WORK statement. In databases that are created
with the MODE ANSI option, no need exists to mark the beginning of a transaction. One is always in effect;
you indicate only the end of each transaction.

In both methods, to specify the end of a successful transaction, execute the COMMIT WORK statement. This statement tells the database
server that you reached the end of a series of statements that must succeed together. The database server does whatever is necessary
to make sure that all modifications are properly completed and committed to disk.

A program can also cancel a transaction deliberately by executing the ROLLBACK WORK statement. This statement asks the database
server to cancel the current transaction and undo any changes.

Informix SQL Guide

http://www.ics.uci.edu/~dbclass/ics184/htmls/Informix_guide.html

Dynamic SQL - with Informix

  • Dynamic SQL allows a program to form an SQL statement during execution, so that the statement can be determined by user input. The action is performed in two steps.

    1. Preparing a statement

      It uses PREPARE statement to have the database server examine the statement text and prepare it for execution.

          EXEC SQL prepare  from '';

    2. Executing prepared SQL

      It uses EXECUTE statement to execute the prepared statement.

          EXEC SQL execute  from '';

    For instance, if you want to inquire the information of some students, you can use the following dynamic SQL for query:

        EXEC SQL BEGIN DECLARE SECTION;
    int sid;
    char sname[10];
    EXEC SQL END DECLARE SECTION;

    EXEC SQL prepare query_stud from 'select id,name from student where name=?';

    EXEC SQL execute query_stud into :sid, sname using 'Mike';
    printf("Student: (%d, %s)\n", sid, sname);

    EXEC SQL execute query_stud into :sid, sname using 'David';
    printf("Student: (%d, %s)\n", sid, sname);
    The above produces the following results:
        Student: (2, Mike)
    Student: (9, David)

  • Embedded SQL(including cursor)

    SQL statements can be embedded in the C and COBOL program. In C, all the statement is preceded by "EXEC SQL". There is a detail example in the next section.

    A cursor is a special data object that represents the current state of a query. It is used for retrieving multiple resulting rows of query. It is used in 5 steps:

    1. Declaring a Cursor
          EXEC SQL DECLARE  CURSOR FOR ;
    2. Opening a Cursor
          EXEC SQL OPEN ;
    3. Fetching Rows
          EXEC SQL FETCH ;
    4. Closing a Cursor
          EXEC SQL CLOSE ;
    5. Freeing a Cursor
          EXEC SQL FREE ;
      For instance, the following program lists the information of all students.
          EXEC SQL BEGIN DECLARE SECTION;
      int sid;
      char sname[10];
      EXEC SQL END DECLARE SECTION;

      EXEC SQL DECLARE cursor_stud CURSOR FOR select id,name from student;
      EXEC SQL OPEN cursor_stud;
      while ( SQLCODE == 0 ) {
      EXEC SQL OPEN cursor_stud INTO :sid, :sname;
      if ( SQLCODE == 0 )
      printf("Student (%d, %s)\n", sid, sname);
      }
      EXEC SQL CLOSE cursor_stud;
      EXEC SQL FREE cursor_stud;
      SQLCODE is set to 0 by the database if the select statement is valid, otherwise set to 100. It is used to detect the end of data.


Informix Programming Guide Setting Environment
  • setenv INFORMIXSERVER rodan_ius_net
  • setenv PATH $INFORMIXDIR/bin:$PATH
  • setenv LD_LIBRARY_PATH $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql:$INFORMIXDIR/lib/dmi:$INFORMIXDIR/lib/c++

How do I compile ESQL/C code for use with C++?

There have been a variety of answers, but not any one systematic answer.
Now there is what I believe is a definitive answer -- it's all in the
attached shell archive.

What do you get?
* Updated ESQL/C prototypes for 4.00, 4.1x, 5.0x and 7.2x
* An esql++ compiler
* A pair of patch files for modifying your standard ESQL/C compiler.
Only use these if your ESQL/C is version 4.1 or 5.x; later versions
already have the necessary change).
* A minimal test application.
* No documentation apart from this message!

What do you need to do?
* Unpack the shell archive.
* Place the esql* headers in either $INFORMIXDIR/incl (version 4)
or $INFORMIXDIR/incl/esql (version 5 or later)
* Place the esql++ script in $INFORMIXDIR/bin
* Decide which version of ESQL/C you are using and set the
ESQLC_VERSION environment variable to a value such as:
export ESQLC_VERSION=506 # 5.06.UC1
* Optionally modify esql++ to give the correct default value of
of ESQLC_VERSION.
* Decide which C++ compiler you use -- if it isn't CC, set:
export INFORMIXC=g++
* Try compiling the test application:
esql++ -o testapp testmain.ec testsub.ec
* Run it against your local stores database -- it should say '2'.

What if you can't modify your INFORMIXDIR?
* Copy $INFORMIXDIR/bin/esql to somewhere where you can modify it
(eg /some/where/bin/esql)
* Patch it if necessary.
* Place the headers in another directory (eg /some/where/include).
* Modify esql++ so that:
-- arglist starts of with -I/some/where/include as one component
-- ESQL defaults to /some/where/bin/esql
* If you don't have to patch the esql script, you don't have to copy it
to /some/where/bin and you don't need to make the corresponding
modification in the esql++ script.

What about other versions of ESQL/C?
* If you are still using a pre-4.00 version of ESQL/C, the chances are
that the code which edits the 4.xx code will be useful. However, the
prototypes for the ESQL/C interface functions are not known and will
have to be determined by inspection of the generated code. Good luck!
It will probably be easier to upgrade to a later version.
* I haven't been able to test version 8.xx ESQL/C; it isn't available to
me. However, the indications are that it will need the same treatment
as the other post-5.00 implementations of ESQL/C.
* Testing with the version 9.10 ESQL/C compiler indicates that this
script is still necessary.
* Ideally, you won't need this script at all for post-9.xx versions. If
you are using some later version, you will need to revise the script so
that the case statement on $ESQLC_VERSION handles the new (presumably
4-digit) version number.
* Note that ESQL/C 7.24 has some support for C++ built in. In
particular, it preprocesses files with the .ecpp extension and then
compiles them with the C++ compiler. It may not link the object code
with the C++ compiler; if it doesn't, you'd have to do that by running
the link command it with INFORMIXC="C++ compiler" in the environment.

Which versions of ESQL/C are are known to work with this?
* The code has been tested against Informix-ESQL/C versions 4.12.UC1,
5.06.UC1, 6.00.UE1, 7.13.UC1, 7.22.UC2, 9.10.UC2 on a Sun Sparc 20
running Solaris 2.5.1 with both SUNWspro C++ SPARCompiler SC4.0.1 and
GNU G++ 2.7.2.2.

Are there any known bugs?
* Life will get very difficult if you pass arguments with quotes or
spaces in them to your compiler:

esql++ -DOPENQUOTE="'" -DSOMMAT="string with blanks" thingy.ec

I do have a solution: it is another program called escape which
deals with precisely that sort of problem.
arglist="$arglist `escape $arg`"
But that requires some more source and isn't generally necessary.
Also, the underlying esql script does not work reliably with such
arguments, so the changes needed are even more extensive.

* The esql7_20.h header is needed until bug B73951 is fixed.

Wednesday, February 27, 2008

GSM main Features

  • Short Message Service which allows you to send and receive 126 character text messages
  • Ability to use same phone in a number of network-related countries
  • Allows data transmission and reception across GSM networks at speeds up to 9,600 bps currently
  • Allows fax transmission and reception across GSM networks at speeds up to 9,600 bps currently
  • Forwarding of calls to another number
  • More capacity, ensuring rapid call set-up. Handsets also smaller and more robust.
  • Talk to a number of other parties simultaneously
  • Place a call on Hold while you access another call
  • Notifies you of another call whilst on a call
  • Encrypted conservations that cannot be tapped
  • You can barr outgoing calls and incoming calls
  • CLIP Allows you to see the telephone number of the incoming caller on the LCD screen of the handset
  • CLIR allows you to bar anyone from seeing your number via CLIP
  • Real-time call costs on the handsets's LCD screen
  • Allows location/cell-specific reception of text messages.
  • Closed User Group - Allows a set of phones to be classed as PBX extensions.
  • Emergency Calls - In the majority of countries, the global 112 emergency number can be dialled free.
  • No-static connections

What Does GSM Stand for?

The T-Mobile PCS network uses GSM technology. GSM stands for Global System for Mobile Communications.
GSM is the international digital radio standard created by the European Telecommunications Standards Institute.
GSM allows users to roam freely among markets. It has become the globally accepted standard since the first systems
began commercial operation in 1991. In the United States, the American National Standards Institute (ANSI) has accepted
GSM-based mobile phone 1900 as a standard for the mobile phone frequencies allocated by the Federal Communications Commission (FCC)
at 1900 MHz.

Linux Signals

Signals

Linux Signals are:

Signal NameNumberDescription
SIGHUP1Hangup (POSIX)
SIGINT2Terminal interrupt (ANSI)
SIGQUIT3Terminal quit (POSIX)
SIGILL4Illegal instruction (ANSI)
SIGTRAP5Trace trap (POSIX)
SIGIOT6IOT Trap (4.2 BSD)
SIGBUS7BUS error (4.2 BSD)
SIGFPE8Floating point exception (ANSI)
SIGKILL9Kill(can't be caught or ignored) (POSIX)
SIGUSR110User defined signal 1 (POSIX)
SIGSEGV11Invalid memory segment access (ANSI)
SIGUSR212User defined signal 2 (POSIX)
SIGPIPE13Write on a pipe with no reader, Broken pipe (POSIX)
SIGALRM14Alarm clock (POSIX)
SIGTERM15Termination (ANSI)
SIGSTKFLT16Stack fault
SIGCHLD17Child process has stopped or exited, changed (POSIX)
SIGCONT18 Continue executing, if stopped (POSIX)
SIGSTOP19Stop executing(can't be caught or ignored) (POSIX)
SIGTSTP20Terminal stop signal (POSIX)
SIGTTIN21Background process trying to read, from TTY (POSIX)
SIGTTOU22Background process trying to write, to TTY (POSIX)
SIGURG23Urgent condition on socket (4.2 BSD)
SIGXCPU24CPU limit exceeded (4.2 BSD)
SIGXFSZ25File size limit exceeded (4.2 BSD)
SIGVTALRM26Virtual alarm clock (4.2 BSD)
SIGPROF27Profiling alarm clock (4.2 BSD)
SIGWINCH28Window size change (4.3 BSD, Sun)
SIGIO29I/O now possible (4.2 BSD)
SIGPWR30Power failure restart (System V)

The kill Command

You can use the kill command to stop or merely pause the execution of a process. You might want to kill a "runaway" process that is consuming CPU and memory for no apparent reason; you might also want to kill the processes belonging to an intruder. kill works by sending a signal to a process. Particularly useful signals are described in detail below. The syntax of the kill command is:

kill [-signal] process-IDs 

The kill command allows signals to be specified by their names in most modern versions of UNIX. To send a hangup to process #1, for example, type:

# kill -HUP 1

With some older versions of UNIX, you must specify the signal by number:

# kill -1 1

The superuser can kill any process; other users can kill only their own processes. You can kill many processes at a time by listing all of their PIDS on the command line:

# kill -HUP 1023 3421 3221

By default, kill sends signal 15 (SIGTERM), the process-terminate signal. Berkeley-derived systems also have some additional options to the kill command:

  • If you specify 0 as the PID, the signal is sent to all the processes in your process group.

  • If you specify -1 as a PID and you are not the superuser, the signal is sent to all processes having the same UID as you.

  • If you specify -1 as a PID and you are the superuser, the signal is sent to all processes except system processes, process #1, and yourself.

  • If you specify any other negative value, the signal is sent to all processes in the process group numbered the same as the absolute value of your argument.

To send any signal, you must have the same real or effective UID as the target processes or you must be operating as the superuser.

Many signals, including SIGTERM, can be caught by programs. With a caught signal, a programmer has three choices of action:

  • Ignore it.

  • Perform the default action.

  • Execute a program-specified function.

There are two signals that cannot be caught: signal 9 ( SIGKILL) and signal 17 ( SIGSTOP).

One signal that is very often sent is signal 1 ( SIGHUP), which simulates a hangup on a modem. Standard practice when killing a process is to first send signal 1 (hangup); if the process does not terminate, then send it signal 15 (software terminate), and finally signal 9 (sure kill).

Sometimes simply killing a rogue process is the wrong thing to do: you can learn more about a process by stopping it and examining it with some of UNIX's debugging tools than by "blowing it out of the water." Sending a process a SIGSTOP will stop the process but will not destroy the process's memory image.

Under most modern versions of UNIX, you can use the gcore program to generate a core file of a running process, which you can then leisurely examine with adb (a debugger), dbx (another debugger), or gdb (yet another debugger). If you simply want to get an idea of what the process was doing, you can run strings (a program that finds printable strings in a binary file) over the core image to see what files it was referencing.

A core file is a specially formatted image of the memory being used by the process at the time the signal was caught. By examining the core file, you can see what routines were being executed, register values, and more. You can also fill your disk with a core file - be sure to look at the memory size of a process via the ps command before you try to get its core image!

NOTE: Some versions of UNIX name core files core.####, where #### is the PID of the process that generated the core file, or name.core, where name is the name of the program's executable.

Programs that you run may also dump core if they receive one of the signals that causes a core dump. On systems without a gcore program, you can send a SIGEMT or SIGSYS signal to cause the program to dump core. That method will work only if the process is currently in a directory where it can write, if it has not redefined the action to take on receiving the signal, and if the core will not be larger than the core file limits imposed for the process's UID. If you use this approach, you will also be faced with the problem of finding where the process left the core file!

Mixing C and C++ Code in the Same Program


Accessing C Code From Within C++ Source

The C++ language provides a "linkage specification" with which you declare that a function or object follows the program linkage conventions for a supported language. The default linkage for objects and functions is C++. All C++ compilers also support C linkage, for some compatible C compiler.

When you need to access a function compiled with C linkage (for example, a function compiled by the C compiler), declare the function to have C linkage. Even though most C++ compilers do not have different linkage for C and C++ data objects, you should declare C data objects to have C linkage in C++ code. With the exception of the pointer-to-function type, types do not have C or C++ linkage.


Declaring Linkage Specifications
Use one of the following notations to declare that an object or function has the linkage of language language_name:

extern "language_name" declaration ;
extern "language_name" { declaration ; declaration ; ... }

The first notation indicates that the declaration (or definition) that immediately follows has the linkage of language_name. The second notation indicates that everything between the curly braces has the linkage of language_name, unless declared otherwise. Notice that you do not use a semicolon after the closing curly brace in the second notation.

You can nest linkage specifications, but they do not create a scope. Consider the following example:

extern "C" {
void f(); // C linkage
extern "C++" {
void g(); // C++ linkage
extern "C" void h(); // C linkage
void g2(); // C++ linkage
}
extern "C++" void k();// C++ linkage
void m(); // C linkage
}

All the functions above are in the same global scope, despite the nested linkage specifiers.


Including C Headers in C++ Code
If you want to use a C library with its own defining header that was intended for C compilers, you can include the header in extern "C" brackets:

extern "C" {
#include "header.h"
}

Warning-

Do not use this technique for system headers on the Solaris OS. The Solaris headers, and all the headers that come with Sun C and C++ compilers, are already configured for use with C and C++ compilers. You can invalidate declarations in the Solaris headers if you specify a linkage.


Creating Mixed-Language Headers
If you want to make a header suitable for both C and C++ compilers, you could put all the declarations inside extern "C" brackets, but the C compiler does not recognize the syntax. Every C++ compiler predefines the macro __cplusplus, so you can use that macro to guard the C++ syntax extensions:

#ifdef __cplusplus
extern "C" {
#endif
... /* body of header */
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif


Adding C++ features to C structs
Suppose you want to make it easier to use a C library in your C++ code. And suppose that instead of using C-style access you might want to add member functions, maybe virtual functions, possibly derive from the class, and so on. How can you accomplish this transformation and ensure the C library functions can still recognize the struct? Consider the uses of the C struct buf in the following example:

struct buf {
char* data;
unsigned count;
};
void buf_clear(struct buf*);
int buf_print(struct buf*); /* return status, 0 means fail */
int buf_append(struct buf*, const char*, unsigned count); /* same return */

You want to turn this struct into a C++ class and make it easier to use with the following changes:

extern "C" {
#include "buf.h"
}
class mybuf { // first attempt -- will it work?
public:
mybuf() : data(0), count(0) { }
void clear() { buf_clear((buf*)this); }
bool print() { return buf_print((buf*)this); }
bool append(const char* p, unsigned c)
{ return buf_append((buf*)this, p, c); }
private:
char* data;
unsigned count;
};

The interface to the class mybuf looks more like C++ code, and can be more easily integrated into an Object-Oriented style of programming -- if it works.

What happens when the member functions pass the this pointer to the buf functions? Does the C++ class layout match the C layout? Does the this pointer point to the data member, as a pointer to buf does? What if you add virtual functions to mybuf?

The C++ standard makes no promises about the compatibility of buf and class mybuf. This code, without virtual functions, might work, but you can't count on it. If you add virtual functions, the code will fail using compilers that add extra data (such as pointers to virtual tables) at the beginning of a class.

The portable solution is to leave struct buf strictly alone, even though you would like to protect the data members and provide access only through member functions. You can guarantee C and C++ compatibility only if you leave the declaration unchanged.

You can derive a C++ class mybuf from the C struct buf, and pass pointers to the buf base class to the mybuf functions. If a pointer to mybuf doesn't point to the beginning of the buf data, the C++ compiler will adjust it automatically when converting a mybuf* to a buf*. The layout of mybuf might vary among C++ compilers, but the C++ source code that manipulates mybuf and buf objects will work everywhere. The following example shows a portable way to add C++ and Object-Oriented features to a C struct.

extern "C" {
#include "buf.h"
}
class mybuf : public buf { // a portable solution
public:
mybuf() : data(0), count(0) { }
void clear() { buf_clear(this); }
bool print() { return buf_print(this); }
bool append(const char* p, unsigned c)
{ return buf_append(this, p, c); }
};

C++ code can freely create and use mybuf objects, passing them to C code that expects buf objects, and everything will work together. Of course, if you add data to mybuf, the C code won't know anything about it. That's a general design consideration for class hierarchies. You also have to take care to create and delete buf and mybuf objects consistently. It is safest to let C code delete (free) an object if it was created by C code, and not allow C code to delete a mybuf object.


Accessing C++ Code From Within C Source

If you declare a C++ function to have C linkage, it can be called from a function compiled by the C compiler. A function declared to have C linkage can use all the features of C++, but its parameters and return type must be accessible from C if you want to call it from C code. For example, if a function is declared to take a reference to an IOstream class as a parameter, there is no (portable) way to explain the parameter type to a C compiler. The C language does not have references or templates or classes with C++ features.

Here is an example of a C++ function with C linkage:

#include 
extern "C" int print(int i, double d)
{
std::cout << "i = " << i << ", d = " << d;
}

You can declare function print in a header file that is shared by C and C++ code:

#ifdef __cplusplus
extern "C"
#endif
int print(int i, double d);

You can declare at most one function of an overloaded set as extern "C" because only one C function can have a given name. If you need to access overloaded functions from C, you can write C++ wrapper functions with different names as the following example demonstrates:

int    g(int);
double g(double);
extern "C" int g_int(int i) { return g(i); }
extern "C" double g_double(double d) { return g(d); }

Here is the example C header for the wrapper functions:

int g_int(int);
double g_double(double);

You also need wrapper functions to call template functions because template functions cannot be declared as extern "C":

template T foo(T t) { ... }
extern "C" int foo_of_int(int t) { return foo(t); }
extern "C" char* foo_of_charp(char* p) { return foo(p); }

C++ code can still call the the overloaded functions and the template functions. C code must use the wrapper functions.


Accessing C++ Classes From C

Can you access a C++ class from C code? Can you declare a C struct that looks like a C++ class and somehow call member functions? The answer is yes, although to maintain portability you must add some complexity. Also, any modifications to the definition of the C++ class you are accessing requires that you review your C code.

Suppose you have a C++ class such as the following:

class M {
public:
virtual int foo(int);
// ...
private:
int i, j;
};

You cannot declare class M in your C code. The best you can do is to pass around pointers to class M objects, similar to the way you deal with FILE objects in C Standard I/O. You can write extern "C" functions in C++ that access class M objects and call them from C code. Here is a C++ function designed to call the member function foo:

extern "C" int call_M_foo(M* m, int i) { return m->foo(i); }

Here is an example of C code that uses class M:

struct M; /* you can supply only an incomplete declaration */
int call_M_foo(struct M*, int); /* declare the wrapper function */
int f(struct M* p, int j) /* now you can call M::foo */
{ return call_M_foo(p, j); }


Mixing IOstream and C Standard I/O

You can use C Standard I/O, from the standard C header , in C++ programs because C Standard I/O is part of C++.

Any considerations about mixing IOstream and Standard I/O in the same program therefore do not depend on whether the program contains C code specifically. The issues are the same for purely C++ programs that use both Standard I/O and IOstreams.

Sun C and C++ use the same C runtime libraries, as noted in the section about compatible compilers. Using Sun compilers, you can therefore use Standard I/O functions freely in both C and C++ code in the same program.

The C++ standard says you can mix Standard I/O functions and IOstream functions on the same target "stream", such as the standard input and output streams. But C++ implementations vary in their compliance. Some systems require that you call the sync_with_stdio() function explicitly before doing any I/O. Implementations also vary in the efficiency of I/O when you mix I/O styles on the same stream or file. In the worst case, you get a system call per character input or output. If the program does a lot of I/O, the performance might be unacceptable.

The safest course is to stick with Standard I/O or IOstream styles on any given file or standard stream. Using Standard I/O on one file or stream and IOstream on a different file or stream does not cause any problems.


Working with Pointers to Functions

A pointer to a function must specify whether it points to a C function or to a C++ function, because it is possible that C and C++ functions use different calling conventions. Otherwise, the compiler does not know which kind of function-calling code to generate. Most systems do not have have different calling conventions for C and C++, but C++ allows for the possibility. You therefore must be careful about declaring pointers to functions, to ensure that the types match. Consider the following example:

typedef int (*pfun)(int);  // line 1
extern "C" void foo(pfun); // line 2
extern "C" int g(int) // line 3
...
foo( g ); // Error! // line 5

Line 1 declares pfun to point to a C++ function, because it lacks a linkage specifier.
Line 2 therefore declares foo to be a C function that takes a pointer to a C++ function.
Line 5 attempts to call foo with a pointer to g, a C function, a type mis-match.

Be sure to match the linkage of a pointer-to-function with the functions to which it will point. In the following corrected example, all declarations are inside extern "C" brackets, ensuring that the types match.

extern "C" {
typedef int (*pfun)(int);
void foo(pfun);
int g(int);
}
foo( g ); // now OK

Pointers to functions have one other subtlety that occasionally traps programmers. A linkage specification applies to all the parameter types and to the return type of a function. If you use the elaborated declaration of a pointer-to-function in a function parameter, a linkage specification on the function applies to the pointer-to-function as well. If you declare a pointer-to-function using a typedef, the linkage specification of that typedef is not affected by using it in a function declaration. For example, consider this code:

typedef int (*pfn)(int);
extern "C" void foo(pfn p) { ... } // definition
extern "C" void foo( int (*)(int) ); // declaration

The first two lines might appear in a program file, and the third line might appear in a header where you don't want to expose the name of the private typedef. Although you intended for the declaration of foo and its definition to match, they do not. The definition of foo takes a pointer to a C++ function, but the declaration of foo takes a pointer to a C function. The code declares a pair of overloaded functions.

To avoid this problem, use typedefs consistently in declarations, or enclose the typedefs in appropriate linkage specifications. For example, assuming you wanted foo to take a pointer to a C function, you could write the definition of foo this way:

extern "C" {
typedef int (*pfn)(int);
void foo(pfn p) { ... }
}


Working with C++ Exceptions

Propagating Exceptions
What happens if you call a C++ function from a C function, and the C++ function throws an exception? The C++ standard is somewhat vague about whether you can expect exceptions to behave properly, and on some systems you have to take special precautions. Generally, you must consult the user manuals to determine whether the code will work properly.

No special precautions are necessary with Sun C++. The exception mechanism in Sun C++ does not affect the way functions are called. If a C function is active when a C++ exception is thrown, the C function is passed over in the process of handling the exception.


Mixing Exceptions with set_jmp and long_jmp
The best advice is not to use long_jmp in programs that contain C++ code. The C++ exception mechanism and C++ rules about destroying objects that go out of scope are likely to be violated by a long_jmp, with unpredictable results. Some compilers integrate exceptions and long_jmp, allowing them to work together, but you should not depend on such behavior. Sun C++ uses the same set_jmp and long_jmp as the C compiler.

Many C++ experts believe that long_jmp should not be integrated with exceptions, due to the difficulty of specifying exactly how it should behave.

If you use long_jmp in C code that you are mixing with C++, ensure that a long_jmp does not cross over an active C++ function. If you cannot ensure that, see if you can compile that C++ code with exceptions disabled. You still might have problems if the destructors of local objects are bypassed.


Linking the Program

At one time, most C++ compilers required that function main be compiled by the C++ compiler. That requirement is not common today, and Sun C++ does not require it. If your C++ compiler needs to compile the main function but you cannot do so for some reason, you can change the name of the C main function and call it from a wrapper version of C++ main. For example, change the name of the C main function to C_main, and write this C++ code:

extern "C" int C_main(int, char**); // not needed for Sun C++
int main(int argc, char** argv) { return C_main(argc, argv); }

Of course, C_main must be declared in the C code to return an int, and it will have to return an int value. As noted above, you do not need to go to this trouble with Sun C++.

Even if your program is primarily C code but makes use of C++ libraries, you need to link C++ runtime support libraries provided with the C++ compiler into your program. The easiest and best way to do that is to use the C++ compiler driver to do the linking. The C++ compiler driver knows what libraries to link, and the order in which to link them. The specific libraries can depend on the options used when compiling the C++ code.

Suppose you have C program files main.o, f1.o, and f2.o, and you use a C++ library helper.a. With Sun C++, you would issue the command

CC -o myprog main.o f1.o f2.o helper.a

The necessary C++ runtime libraries like libCrun and libCstd are linked automatically. The documentation for helper.a might require that you use additional link-time options. If you can't use the C++ compiler for some reason, you can use the -dryrun option of the CC command to get the list of commands the compiler issues, and capture them into a shell script. Since the exact commands depend on command-line options, you should review the output from -dryrun with any change of the command line.


For More Information

- Sun ONE Studio C/C++ Documentation
Latest information on the Sun ONE C and C++ compilers and tools, including man pages and readme files.

extern usage

The extern keyword declares a variable or function and specifies that it has external linkage
(its name is visible from files other than the one in which it's defined). When modifying a variable, extern specifies that
the variable has static duration (it is allocated when the program begins and deallocated when the program ends).
The variable or function may be defined in another source file, or later in the same file.
Declarations of variables and functions at file scope are external by default.
In C++, when used with a string, extern specifies that the linkage conventions of another language are being used for the declarator(s).
C functions and data can be accessed only if they are previously declared as having C linkage. However, they must be defined in a
separately compiled translation unit.

Anti-crash With const

You must use const at every opportunity. The const is your most powerful anti-crash weapon. An additional benefit is that it makes your code self-documenting. For instance, look at this:


const char *add2strings(const char *sz1, const char *sz2);

Such a declaration guarantee's that no matter what wierd things go on within the function, it can't harm the application programmer's two strings sz1 and sz2. If any memory corruption occurs, it will be to variables within the function's scope. This, of course, greatly reduces side effect bugs.

Furthermore, the declaration of the return pointer as const means that the application programmer can't "reach inside" the function to corrupt its scope. For instance, if the return value is a static array of 40 characters, if the return wasn't static the application programmer could do this:


char *pchName = add2strings("James", "Bond 007");
strcat(pchName, " jumps out of the plane and parachutes down");
cout << "I just corrupted an internal variable of add2strings. ";
cout << "Will I see this message?\n";
cout << "Will it crash later in the program? Who knows!\n";

Fortunately, because add2strings() returns a const pointer, you'll get a compiler error on this:

char *pchName = add2strings("Big galaxies", "Big stars");

Even if you declared pchName as a const char *, the moment you modified its contents with strcat() you'd get a compile error. The const keyword helps the programmer keep any errors localized, thus greatly reducing the likelihood of side-effect errors.

C++ Programming HOW-TO

Good Link for learning CPP Programming :

http://www.oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO.html#toc1

Name Mangling

Name mangling is the encoding of function and variable names into unique names so that linkers can separate common names in the language.
Type names may also be mangled. The compiler generates function names with an encoding of the types of the function arguments when the
module is compiled. Name mangling is commonly used to facilitate the overloading feature and visibility within different scopes.
Name mangling also applies to variable names. If a variable is in a namespace,
the name of the namespace is mangled into the variable name so that the same variable name can exist in more than one namespace.
The C++ compiler also mangles C variable names to identify the namespace in which the C variable resides.

The scheme for producing a mangled name differs with the object model used to compile the source code:
the mangled name of an object of a class compiled using one object model will be different from that of an object of the same class
compiled using a different object model. The object model is controlled by compiler option or by pragma.

Name mangling is not desirable when linking C modules with libraries or object files compiled with a C++ compiler.
To prevent the C++ compiler from mangling the name of a function, you can apply the extern "C" linkage specifier to the declaration
or declarations, as shown in the following example:

extern "C" {
int f1(int);
int f2(int);
int f3(int);
};

This declaration tells the compiler that references to the functions f1, f2, and f3 should not be mangled.

The extern "C" linkage specifier can also be used to prevent mangling of functions that are defined in C++ so that they can be
called from C. For example,

extern "C" {
void p(int){
/* not mangled */
}
};

Monday, February 25, 2008

Budget why and how

Why budget

To function effectively and discharge all its duties and obligations, every government needs resources. Through the budgetary process, the Indian Parliament authorises the government of the day to collect funds by way of taxes, duties, cess, borrowings and so on. The funds so collected by the government are used, with the approval of Parliament, to meet its expenditure.

The President of India is obliged constitutionally to have the Annual Financial Statement for the ensuing financial year laid on the table of the House under Article 112. But, according to Article 77(3), the Finance Minister has been made responsible to prepare the Annual Financial Statement and pilot it through Parliament. This Annual Financial Statement is called the budget.

The Team

The Finance Minister prepares the Union Budget and budgets of those states under President's Rule. Though the ministry of finance has the overall responsibility of framing the budget, other organs of the state are also involved in budget-making. These include;

1) The Planning Commission

Planning Commission sets overall targets for the ministries

2) The Comptroller & Auditor General

C&AG keeps a check on accounts

3) Administrative Ministries

Finance Minister has to consult the administrative ministries for their requirements and to incorporate plan priorities.

The finance ministry

In common usage, the budget is referred to as being the Finance Minister's speech and the documents tabled on the day of the budget. The actual process, however, starts much earlier and continues even after the budget is presented to Parliament. Each department in the finance ministry is charged with a particular responsibility.

Expenditure
Department of Expenditure

Revenue
Non-Tax — Department of Economic Affairs

Tax— Department of Revenue

Deficit

Department of Economic affairs

The process

The budget exercise kicks off in September every year with the issue of a budget circular by the Budget Division of the Department of Economic Affairs (DoE) to all Union Ministries, all states and UTs, autonomous bodies and departments and the three arms of the defence forces for preparing revised estimates for the current financial year and the budget estimate for the next financial year .The circular for 2008-09 budget was issued on September 20, 2007. It contained guidance to ministries/departments for framing the Revised Estimates for 2007-2008 and Budget Estimates for 2008-2009.

Due dates

Due dates for rendition of estimates for 2008-09 budget by ministries/departments to Budget Division of Department of Economic Affairs are:

October 26 ,2007
Interest receipts/recoveries of loans

October 26,2007
Capital receipts (including public account transactions)

October 31,2007
Statement of ( proposed ) Budget Estimates (SBE)

November 30,2007
Revenue receipts

Immediately after ceilings are communicated

Statement of Budget Estimates (final)Within 3 days of receipt of plan allocation from Planning Commission

SBE with BE 2008-2009 (Plan)

Notes on Demands for Expenditure Budget Vol. 2

Material for statements to be appended to Demands for Grants/Expenditure Budget.


Administrative ministries: After the line ministries submit relevant documents, pre-budget meetings begin. These involve extensive consultations between line ministries and the Department of Expenditure.

Interest Groups :Meanwhile the Department of Economic Affairs and Department of Revenue engage with stakeholders such as farmers, labour unions, business, FIIs, economists and civil society groups.

.State Governments: Demands to the state governments are sent to the concerned finance ministry departments for evaluation.

The finance ministry also undertakes an intense internal assessment n Spending priority-Department of Economic Affairs n Revenue mobilisation-Department of Revenue n Aligning with policy goals-Department of Economic Affairs

Once the pre-budget meetings are over, the approved ceiling for expenditure, as finalised in these meetings, is communicated. It includes internal ceilings of revenue and capital expenditure. Based on these limits, each ministry/department will prepare a final statement of budget estimates (SBE) and send to the budget division

The revenue department goes through all the demands and works out their revenue implications. A final call on the tax proposals is taken by the Finance Minister. The proposals are discussed with the Prime Minister before a final
decision is taken

Budget division then gets on with the task of preparing the budget documents. There are 13+ core documents.

How the budget is passed

1. The Budget is presented to Parliament on a date fixed by the President. By convention, since1999, it is being presented at 11 A.M. on the last working day of February

2. The budget session of Parliament opens with the address by the President.

Presentation

.Finance minister presents the Budget in the Lok Sabha

The Budget speech of the FM has two parts. Part A deals with general economic survey of the country and policy statements while Part B contains

Taxation proposals

‘Annual Financial Statement’ is laid on the Table of Rajya Sabha after the FM’s speech

Discussion

1. No discussion follows immediately after the budget is presented.

2. Few days later the Lok Sabha discusses the Budget as a whole and not the details for 2 to 3 days.

3. The FM makes a reply at the end of the discussion.

4. A ‘Vote on Account’ for expenditure for the next two months of ensuing financial year is obtained from Parliament.

5. The House is adjourned for a fixed period.

6. During this period, the Demands for Grants of various ministries/departments including Railways are considered by relevant standing committees

Vote

Standing Committee reports are presented to the House. It discusses and votes on demands for grants, ministry-wise

.The Speaker puts all the outstanding Demands to the vote of the House. This device is known as the 'guillotine'. The Lok Sabha has the power to assent to or refuse any demand or even to reduce the amount of grant sought by the government
In the Rajya Sabha, there is only a general discussion on the Budget. It does not vote on the Demands for Grants
After the General Discussion on the Budget proposals and voting on Demands for Grants have been completed, government introduces the Appropriation Bill. The Appropriation Bill is intended to give authority to the government to incur expenditure from and out of the Consolidated Fund of India.

Tax Proposals

The Finance Bill seeking to give effect to the government’s taxation proposals, which is introduced in the Lok Sabha immediately after the presentation of the Budget, is taken up for consideration after the Appropriation Bill is passed. However, certain provisions in the Bill relating to levy and collection of fresh duties or variations in the existing duties come into effect immediately on the day the Bill is introduced by virtue of a declaration under the Provisional Collection of Taxes Act. Indirect tax proposals come into force as soon as they are announced; direct tax proposals await approval by Parliament. Parliament has to pass the Finance Bill within 75 days of its introduction.

Documents

Finance Minister tables the following documents in the Lok Sabha

Key to Budget n Budget

Highlights n Budget Speech

.Budget at a Glance

Finance Bill n Memorandum n Receipt Budget n Expenditure Budget n Customs & Central Excise n Implementation of Budget n Announcements 3. The Macro Economic Framework Statement

.The Medium Term Fiscal Policy Statement n The Fiscal Policy Strategy Statement
5. The Outcome Budget

If the budget proposals are defeated in the lok sabha, the government has to resign !

Railway budget

The Railway Budget is presented to Parliament by the union railway minister, two days prior to the General Budget. The Railway Budget figures relating to the receipt and expenditure of the railways are also shown in the General Budget, since they are a part and parcel of the total receipts and expenditure of the Government of India.

The secret world of the finance minister

The entire process of collating data and preparation of the text of the budget document is done by a few selected officials and stenographers working on computers which are de-linked from all networks, including NIC hot link.

Printing of the budget documents

Finance Ministry hands over the CD containing print-ready templates of all budget documents for printing aroundFebruary 24

The Union Budget is printed at the special printing press in the basement of the North Block of the Central Secretariat in New Delhi.

Quarantine

All officials, technicians and workers involved with the printing are quarantined - they have to sleep in North Block

The legal experts on taxation from the law ministry who check the text and wordings of the Tax Acts are also quarantined

The Press Information Bureau officials who prepare press notes in English, Hindi and Urdu on the budget too are quarantined

All quarantined officials walk out of the North Block only after the budget has been tabled by the FM in the Lok Sabha.

The Cabinet gets to see the budget summary only 10 minutes before Parliament assembles for the budget presentation.

To make search Engine search Ur own Blog

You can manually submit your Blog address by clicking following Address:
http://blogsearch.google.com/ping

While it is true that you don't even need to submit your site to
Google in order to be indexed, Google does invite you to submit your
URL to make sure they don't miss your site.

Submit your blog via Google's free submitting form.

http://www.google.com/addurl/?continue=/addurl

7 ACTIONS to be avoided

* Don't smoke- Experiment from experts proves that smoking a cigarette after meal is comparable to smoking 10 cigarettes (chances of cancer is higher).

* Don't eat fruits immediately after meals - Immediately eating fruits after meals will cause stomach to be bloated with air. Therefore take fruit 1-2 hr after meal or 1hr before meal.

* Don't drink tea immediately after meals - Because tea leaves contain a high content of acid. This substance will cause the Protein content in the food we consume to be hardened thus difficult to digest.

* Don't loosen your belt immediately after meals- Loosening the belt after a meal will easily cause the intestine to be twisted & blocked.

* Don't bathe immediately after meals - Bathing will cause the increase of blood flow to the hands, legs & body thus the amount of blood around the stomach will therefore decrease. This will weaken the digestive system in our stomach.

* Don't walk about immediately after meals - People always say that after a meal walk a hundred steps and you will live till 99. In actual fact this is not true. Walking will cause the digestive system to be unable to absorb the nutrition from the food we intake.

* Don't sleep immediately after meals- The food we intake will not be able to digest properly. Thus will lead to gastric & infection in our intestine.

Thursday, February 21, 2008

HR = High Risk (Just for Fun..)

After 2 years of selfless service, a man realized that he has not been promoted, no transfer, no salary increase no commendation and that the Company is not doing any thing about it. So he decided to walk up to his HR Manager one morning and after exchanging greetings, he told his HR Manager his observation.

The boss looked at him, laughed and asked him to sit down saying, My friend, you have not worked here for even one day. The man was surprised to hear this, but the manager went on to explain.

Manager:- How many days are there in a year?
Man:- 365 days and some times 366

Manager:- how many hours make up a day?
Man:- 24 hours

Manager:- How long do you work in a day?
Man:- 8am to 4pm. i.e. 8 hours a day.

Manager:- So, what fraction of the day do you work in hours?
Man:- (He did some arithmetic and said 8/24 hours i.e. 1/3(one third)

Manager:- That is nice of you! What is one-third of 366 days?
Man:- 122 (1/3x366 = 122 in days)

Manager:- Do you come to work on weekends?
Man:- No sir

Manager:- How many days are there in a year that are weekends?
Man:- 52 Saturdays and 52 Sundays equals to 104 days

Manager:- Thanks for that. If you remove 104 days from 122 days, how many days do you now have?
Man:- 18 days.

Manager:- OK! I do give you 2 weeks sick leave every year. Now remove tha t14 days from the 18 days left. How many days do you have remaining?
Man:- 4 days

Manager:- Do you work on New Year day?
Man:- No sir!

Manager:- Do you come to work on workers day?
Man:- No sir!

Manager:- So how many days are left?
Man:- 2 days sir!

Manager:- Do you come to work on the (National holidays)?
Man:- No sir!

Manager:- So how many days are left?
Man:- 1 day sir!

Manager:- Do you work on Christmas day?
Man:- No sir!

Manager:- So how many days are left?
Man:- None sir!

Manager:- So, what are you claiming?
Man:- I have understood, Sir. I did not realise that I was stealing Company money all these days.

Moral - NEVER GO TO HR FOR HELP!!!
HR = HIGH RISK

How Sensex will be Calculated!!!

Following Link show a Good Article Regarding the Sensex calculation.
http://in.rediff.com/money/2008/feb/21bspec.htm

Monday, February 18, 2008

There is no stricmp in Linux

OK. This is a short one. I would say I'm still pretty new to be a real full time Linux developer, so this is the first time I met this problem.

I've been using stricmp() for a long long time but this is the first time I found there's no stricmp() in Linux. Instead, Linux has a similar function called strcasecmp() (also a corresponding strncasecmp() ). Besides that, these two functions are not defined in string.h, instead, they reside in a separate header file called strings.h. That's it.

This is really annoying especially when you are considering portability.

Friday, February 15, 2008

Festivals of India

http://www.festivalsofindia.in/

Review Sites of Mobile and Cams

http://www.reviewcentre.com/

Windows Event Code Analysis

http://www.loganalysis.org/sections/syslog/windows-to-syslog/log-windows.html
http://www.loganalysis.org/
http://www.microsoft.com/technet/archive/security/prodtech/windows2000/secwin2k/swin2k09.mspx?mfr=true

Debugging through the windbg

http://www.alltutes.blogspot.com/

Interview related(Resume Preperation, Questions Preperation...)

http://get-best.com/IT_Interview_Questions/programming.htm

Linux Knowledge Links

http://www.linux-faqs.com/
http://www.linuxtopia.org/online_books/index.html
http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html
http://www.psci.net/~dbklem/books1.html
http://www.linux.org/docs/
lwip download site :
http://www.cse.unsw.edu.au/~cs9242/05/project/liblwip.shtml
The Art of Unix Programming
http://www.catb.org/~esr/writings/taoup/html/
The Linux Kernel Archives
http://www.kernel.org/

UNIX shell scripting with sh/ksh

http://www.dartmouth.edu/~rc/classes/ksh/

Details of GCC Compiler
http://gcc.gnu.org/onlinedocs/gcc/

The Linux kernel Module Programming Guide
http://www.linuxtopia.org/online_books/Linux_Kernel_Module_Programming_Guide/index.html

Linux netfilter Hacking HOWTO
http://www.iptables.org/documentation/HOWTO//netfilter-hacking-HOWTO.html

Linux KernelAnalysis-HOWTO
http://www.linux.org/docs/ldp/howto/KernelAnalysis-HOWTO.html

Advanced Linux Programming
http://www.advancedlinuxprogramming.com/

c/c++ on UNIX/LINUX
http://www.programmersheaven.com/mb/ConLunix/Board.aspx?S=B20000

free Linux Books
http://www.freeprogrammingresources.com/linuxbooks.html

Cracks Database

http://www.cracks.ru/

c knowledge Sites

http://www.cs.cf.ac.uk/Dave/C/CE.html

c++ Books links

http://cpp.datastructures.net/

c++ programming
http://www.cprogramming.com/

c++ Programming Practice Guidelines
http://geosoft.no/development/cpppractice.html

Programming Tutorials
http://www.cprogramming.com/tutorial.html

secure programming
http://madchat.awired.net/coding/c/c.seku/

computer Drivers Search

http://driverguide.com/

C interview Question Links

http://www.geekinterview.com/Interview-Questions/Languages/C

Online TELUGU movies Links

http://saradaga.com/
http://www.fullhyderabad.com/htdocs/arts/movies.html
http://www.cinegoer.com/videosongs/a.htm

Exam Result Sites

All type of Exam Results : http://www.winentrance.com/

CBSE Results Link

http://cbseresults.nic.in/aieee/cbseaieee.htm

Links to Free Novals

http://www.free-online-novels.com/

All-in-One Sites ( Techincal Queries)

http://www.aota.net/
http://www.codeproject.com/

Customer Care NUmbers for various Banks

http://www.arjunprabhu.com/blog/archives/2005/09/19/customer-care-numbers/

online Travel Booking Sites

Dhanunjaya Travels : http://www.dhanunjayatravels.com/
http://www.kesinenitravels.com/

Indian Railway related Sites

http://www.indianrail.gov.in/
Specific Train Enquary : http://www.trainenquiry.com/indexNS.aspx

http://www.erail.in/

cricket score sites

http://scores.sify.com/
http://www.cricinfo.com/

Links for Database Books Downloads

http://www.programmerworld.net/books/database.htm

unix knowledge LInks

http://www.ee.ic.ac.uk/docs/software/unix/
vi Editor Knowlwdge Link : http://www.eng.hawaii.edu/Tutor/vi.html

c-shell tutorial Links

http://www.linux-tutorial.info/modules.php?name=MContent&pageid=29

Finance Related Sites

http://bseindia.com/
http://www.moneycontrol.com/stocksmarketsindia/
Good Link to See before Going to investment :
http://www.personalfn.com/

Good Book Sites

http://www.unix.org.ua/orelly/
http://allfreedownloadlinks.com/
Blue Portal : http://www.zillr.com/
http://www.itslals.com/

Understanding LDAP - Design and Implementation
http://www.redbooks.ibm.com/abstracts/sg244986.html
http://www.alltutes.blogspot.com/

Dada Photos




Posted by Picasa