Monday, October 26, 2009

Thursday, September 03, 2009

Pioneer car audio models

Those who looking for Pioneer car audio system , here is the link
It got a variety range of products its good to buy a headunit with rear USB.

http://www.team-bhp.com/forum/product-discussions/32176-new-pioneer-car-systems-launched-3.html

And for speakers I am going with polk audio DB691

Friday, July 10, 2009

How do I find the current machines full hostname in C (hostname and domain information)?

I was searching a easy method to get hostname , when i googled i got some info and here i added some of them and also some tried on my comp of my own , it may come handy sometime never know ;-)

To get a fully qualified name for a machine, we must first get the local hostname, and then lookup the canonical name.

The easiest way to do this is by first getting the local hostname using uname() or gethostname() and then performing a lookup with gethostbyname() and looking at the h_name member of the struct it returns. If you are using ANSI c, you must use uname() instead of gethostname().

Example:

char hostname[1024];
hostname[1023] = '\0';
gethostname(hostname, 1023);
printf("Hostname: %s\n", hostname);
struct hostent* h;
h = gethostbyname(hostname);
printf("h_name: %s\n", h->h_name);
Unfortunately, gethostbyname() is deprecated in the current POSIX specification, as it doesn't play well with IPv6. A more modern version of this code would use getaddrinfo().

Example:

struct addrinfo hints, *info, *p;
int gai_result;

char hostname[1024];
hostname[1023] = '\0';
gethostname(hostname, 1023);

memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; /*either IPV4 or IPV6*/
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;

if ((gai_result = getaddrinfo(hostname, "http", &hints, &info)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai_result));
exit(1);
}

for(p = info; p != NULL; p = p->ai_next) {
printf("hostname: %s\n", p->ai_canonname);
}
Of course, this will only work if the machine has a FQDN to give - if not, the result of the getaddrinfo() ends up being the same as the unqualified hostname.

One more method to find hostname is using uname command
#uname -a [which is a command line utility]

If you want to use in prigram you can use uname() system call (I often use in my code)
#include

main()
{
struct utsname buf;
if ( uname(&buf) <>perror("uname");
printf(" hostname= %s ",buf.nodename);
}

uname is a very usefull system call it also provide info like
sysname,release ,version, (whatever you see when you execute uname -a command)

Hope it helps some one seeking for this , as I did ;-)

Tuesday, March 10, 2009

Get Train Details through google talk


My friend Vinod sent this link, when i read subject line i am excited to see now what from google, I read the mail  and tried the links it was simply amazing!. We always complain with IRCTC or any other web portal which don't have any live info here is the answer for that. You can interact with the virtual person ;-) sitting beside cleartrip.
It's very simple to get started

Add cleartrip.trains@gmail.com to your Gtalk friend list to search the Indian railways train.
After ten minutes you see "cleartrip.trains"  is added to your gtalk list and shows available.

So once you are done with this process just type "command" to get commands to interact it will list all the commands available for user (its a kinda help in other terms) as shown below

cleartrip.trains:  
book followed by train number and optionally passenger details - to book ticket. Ex. 'book 2925' and 'book 2925 adults 1 children 2 senior male 1 senior female 1'
pnr pnr number - check pnr status. Ex. 'pnr 123 4567890'
return date - search for return journey. Ex 'return 10th march'
avail train number - check availability of a train. Ex. 'avail 2925'
invite gmail id - invite friends
feedback your message - to send feedback to cleartrip
clear - clear your search history

So i thought i should give a shot to check this i entered following text in the chat window

me:  Bangalore Gulbarga Mar 12 3A
cleartrip.trains:  Searching for trains between Bangalore and GULBARGA on 12 Mar class 3A
6513 - Basava express Rs. 716, @ 17:25 [Available 18]
1014 - Lokmanya tt exp Rs. 738, @ 15:25 [Waitlist 11]
2627 - Karnataka exp Rs. 769, @ 19:20 [Waitlist 6]
6530 - Udyan exp Rs. 738, @ 20:10 [Waitlist 7]

To check availability say 'avail' followed by train number
To book say 'book' followed by train number and passenger details. Ex. 'book 2925 adult 1 child 1 senior female 1'

This is a amazing piece of work .. google is making life a lot more easier 
GOOGLE ROCKS!!!