Wednesday, January 02, 2008

Interesting

Interesting thought...

test.c

#include

class myClass

{

private:

public:

myClass( );

};

int main()

{

printf("Bye world\n");

}


Now I want to compile test.c file using gcc compiler,

gcc test.c

test.c:: error: iostream.h: No such file or directory

test.c:: error: parse error before 'myClass'

test.c:: error: syntax error before '{' token

test.c:: error: parse error before '}' token

How to achieve this...

Rahul is it possible... Any idea....

Satish

Wednesday, October 24, 2007

iPhone SDK ... ?

Apple iPhone made revolution in the world of mobile. iPhone hit the market by its tremendous advanced technologies. That makes it iPhone a huge success.

I am curious...! are there any killer application for iPhone...? I think till now no such softwares hit the market. I could be wrong :-( . The real truth is that Apple did not released any SDK for iPhone. No SDk means no killer application.

Developer are limited to develop only web based application for iPhone. This restricts hackers development to only web based applications like GMail, Google Maps etc to iPhone.

But one good news is that Apple is planning to release iPhone SDK in the early 2008.

So I am curiously waiting to see who will win the race (Apple/Hackers) ...?

Yours,
Satish

Java Native Interface [ JNI ]

JNI is an acronym of Java Native Interface. It is an programming framework for Java software developer to interact with native libraries which were written in some other languages, such as C, C++ ... etc.

The usability of the JNI comes into picture when a Java software developer try to use some of the native or open source libraries which were written in languages other than Java.

I was working on project of similar kind of requirement. The project which I worked the requirement was something like, replacing the Quicktime for Java library with native Quicktime library APIs. The entire project code was in Java. Quicktime for Java library is actually a provides some higher level APIs which intern calls the native Quicktime APIs. Some times this renders some performance issue while running the Java application. And also this lacks some features and is not as good as the native Quicktime library.

The project which I worked was on Mac platform. In that project we developed a JNI shared library which is wrapper layer over Quicktime Mac library.

Start up with the project:

Generate a C header file from the Java class using the below command:

javah [optionns] java_classname

Create a jni library target in your Java application. Add all the source and header files to your newly created target. Final step is that implement all the methods in the header file which was created by javah using your native library.

Load the created the jni shared library from your Java application.

Here I did not mention all the steps in detail. If you find any difficulty in understanding the concept and steps, please raise your comments in the comments column.

If anybody working on the similar requirement, and got struck at any point please share with me through comments. I will try to shed some lights on your issue.

Below is the link to sample code:
http://developer.apple.com/samplecode/MyFirstJNIProject/

Yours,
Satish

Parse .FLV file

Are you working on Adobe flash file parsing...? and found difficulty in parsing the flv file and found difficulty in understanding the flv file specification. Share your difficulties with me.

Fifteen days back I worked on one of the project, in that I did demuxing and muxing of the flv file.

The language we used in the project was C. I faced some issues in the beginning of the project, but somehow I resolved those by googling. So now I am pretty much comfortable with the flv file specification. Now I could be able to parse the entire flv. In the project which I worked we successfully demuxed meta data, cue points, alpha channel, audio and video packets from the flv file. Once the demuxing is done we constructed the flv file back by muxing all the components.

We provided some of the higher level APIs for the user to demux and mux the flv file.

If someone is working on the similar requirement and got struck at some point, please share your difficulty with me. I will try my level best to help you out. If you are in dilemma about which data structure to use to parse flv file, please put forward your thoughts through comments... I will try to share my previous project experience with you all.

If you have any comments on this article, please post your comments....

Yours,
Satish

Cgreen: Unit Test framework for C

Are you looking for simple and easy to use unit test framework for C ...?. If so here we go Cgreen.

Cgreen is a unit tester for the C software developer. This tool is completely open source. This framework provides some rich set of features to test our C code. I personally adopted this framework in my project to my C code. This will definitely reduce lots of debugging time and also helps in developing the quality code.
After adopting this tool in my project , I personally felt that this tool is easy to build and easy to use.

At this point of time I know how to get the things out of this framework.So if anybody wants to use this tool in your project and if you face any issues while using this tool, please share with me.

I will try my level best to help you out.

Educative link to Cgreen:
http://www.lastcraft.com/cgreen.php

Download Cgreen from the below link:
http://sourceforge.net/projects/cgreen

If you have any comments on this article or if you have any ideas, please share with me through your comments....

Yours,
Satish

Why, Background Process

Just an thought about Background Process.
Can't we use background process as remainders...

Consider the following examples... Suppose if we want to print some message on the console after some interval of time, then in such condition we can use background process as remainder.The below chunk of code meets the above requirement.

#include
void main( int argc char *argv[] )
{

int time_sec = 0;
time_sec = atoi ( argv [ 2 ] );
sleep ( time_sec );
printf ( " %s\n ", argv [ 1 ] );

}

Run:./a.out " Hello World " 4Prints Hello World on the console after 4 seconds.

Consider one more useful example, suppose if you would like to copy a large content of data from one file to another. Surely this would take some time to complete the task. Its a very bad practice if we block our main process until the copying process complete. Instead we can create a separate background process and get the task done through that process. This will ensures the smooth flow.

Snippet of code to illustrate copying process...

#include
void main ( int argc, char *argv [] )
{

FILE *readFilePtr, *writeFilePtr;
char c;

readFilePtr = fopen ( " inputFile " , r );
writeFilePtr = fopen ( " outputFile " , w );
while ( c = fgetc ( readFilePtr ) != EOF )fputc ( c, writeFilePtr );
sys_beep( 2 );

}

One more situation wherein which this is useful is, when the system administrators wants to know who are all the users currently logged in to the system at regular interval of time.

Unix command to achieve the above task is: who wc -l

if somebody knows any other situation wherein which these background process are most useful, please share with us...

Yours,
Satish

Monday, April 09, 2007

Mac Users: Add Unit Tests To Your Xcode Project :-

Some people may already know about this, but still I am posting this hint to this Blog with an intension that everybody should aware of this important Xcode supported feature...

A unit test is simply a piece of code that exercises some part of your application. The unit test provides a specific input and expects your code to return a specific output. If your code returns an unexpected value, the unit test reports the lack of compatibility error. This will verify that newly introduced code does not break any existing behavior.

Third-party unit testing modules have been available for Xcode for some time. In addition, Xcode 2.1 now integrates some modules directly into the project environment.

These modules provides the basic testing tools needed to build automated and repeatable test suites.

Support for Objective-C test cases is provided by the SenTestingKit framework.
Support for C and C++ test cases is provided by the CPlusTest framework.

Educative Link:
http://developer.apple.com/documentation/DeveloperTools
/Conceptual/UnitTesting/Articles/CreatingTests.html

Wednesday, March 14, 2007

Power Of Signal Handling

Most of the software engineer / customer are fed up with their application crash. Yesterday I was thinking about the same and got some idea to get rid of this problem to some extent.

Idea is to handle signal in our program, so that our program should get resistant power to war against the bad signals.

I am not sure about whether this is possible or not.

The below snippet of code illustrate the handling of the signal SIGINT.

#include
void main()
{

...
signal( SIGINT, SIG_DFL ) // Default code get executed when the program receives SIGINT signal.
for( ;; )

...


}

We can write our own function to handle the signals in program ( instead of the default code ).

#include

void foo();

void main()
{

...
signal( SIGINT, foo ) // foo() gunction gets executed when the program receives SIGINT signal.
for( ;; )

...


}

void foo()
{

printf( " Program received SIGINT signal \n " );

}

Now the question is,

Is it possible to ignore( filter ) the signals in our program...?

Is it possible to relaunch the crashed application by catching the bad signal thrown by OS without causing any damage to user data...?

Is there any other ways to get rid of this problem...?

Monday, March 12, 2007

Blog Update

The blog has been updated to receive comments from non-members too. So Ravi blog on!

Sunday, February 25, 2007

Selling software

How should a start-up company plan to sell its software?. Selling requires a lot of established infrastructure for which a entrepreneur may not have access to. It could be a distribution channel, promotion etc. All in all what is the basic ingredient required to sell software?

power of 2

Write a program to find if the given number n is a power of 2 or not?

Friday, January 19, 2007

Tech Samachar

http://www.samachar.com/tech/archives/techtalk24.html