Saturday, November 10, 2007

Give windows a “bash”

How many of us, who love the power of command line feel handicapped when it comes to windows, with its pathetic cmd.exe or command.exe, I was missing the auto-completion, multiple tabs, and most importantly the commands, pipes, redirection, tee, I am not sure of the windows equivalents of these, so I was looking for some way to Linux-ify my widows.

Being a TA required me to compile few softwares for windows (skyeye, softgun, arm-elf-gprof etc...), so I had to choose between MinGW and Cygwin, first I started with MinGW and found it quite inadequate, since Cygwin gives a complete Linux environment, I settled for it, but I still miss the tabbed terminals, I was searching for “tabbed command prompt” in google and found a few links but none were open source, some how I stumbled upon a blog where they have mentioned about Console2, an open source one currently under development, so I downloaded it and am pretty happy about it, now i'll give a step by step procedure how I got a almost working gnome-terminal(or Konsole) alike...

  • download and install cygwin
  • download and extract console2
  • open console2
  • press ctrl+s to bring settings dialog
  • go to tabs option, click add change title to you something you want, select cygwin.bat from CYGWIN_HOME, press ok
  • now if you want a cygwin terminal press ctrl+f2 (assuming the cygwin appears below console2)
If you dont want cygwin then you can use gnuwin32 package, and add its wbin folder to path and just use console2 with all the power of unix

Console2: http://sourceforge.net/projects/console

Blogged with Flock

Tuesday, November 6, 2007

infront or infront of back

sounds crazy right, i could not come up with a sexy title for (pre or post increment operators in c), anyways today the issue of pre/post increment operators in c, sagar and i had a good 15 minute discussion how this works so he results are here

int i=5;
printf("%d,%d,%d",++i, i, i++);
/*
output: 7,7,5
*/

how, we understood that printf evaluates from right to left, so it'll do i++ first and return '5' and update value of i i.e. 6 in stack, the middle i is just i, the first ++i, will increment value of i in stack i.e. it becomes 7, now it'll examine the value of stack finds i=7, therefore it substitutes 7 as first and second argument


int i=5;
printf("%d,%d,%d",++i, i, ++i);
/*
output: 7,7,7
*/


how, we understood that printf evaluates from right to left, so it'll do ++i in stack i.e. 6 in stack, the middle i is just i, the first ++i, will increment value of i in stack i.e. it becomes 7, now it'll examine the value of stack finds i=7, therefore it substitutes 7 as first and second argument

because in post increment operator, the assignment happens before increment, therefore in case one 5 is assigned or returned, and get incremented on stack.
fair enough understanding i think.

refer:-

Blogged with Flock

Monday, November 5, 2007

Nurses or NCurses

the first time i saw this package was during Fedora Core 1 installation, a nurses package... what a funny name or is it really for nurses, but i forgot about it.
next comes kernel compilation for Advanced OS class, where make menuconfig reports some error in ubuntu.. after some digging someone found out that we have to install libncurses-dev package for it to work, and i remembered that funny incident that happened 3 years before.

the assignment questions seemed simple
  1. Observing “Linux“ behavior“ by writing a program to use the  /proc  mechanism to inspect various kernel values
  2. Learn how to write a UNIX—style shell program
what big deal, half the program is in book complete it and finish the assignment, my "proc" will intelligently display the status of the program if you give PID, and as an unexpected move Prof SN was completely "satisfied" with our work so we have to redo it.
so i want to add interactivity to my shell , that is history, command completion etc.. , so i have to capture keystrokes, but what shit, ours is not a complete shell, so the shell that we run on didn't give us the keycodes that we expect .. after a lot of blah blah .. nurses or ncurses came to resuce, there is a getch() function will capture all keys if we set keypad(stdsrc,TRUE), done...

worked for three more days to "port".. when every thing is working .. Hmm this is not what i wanted SEGMENTATION FAULT, why the hell!!, Hmm if do chdir() there is a seg fault, i got bugged of curses so had to revert back to non-interactive shell, but i can upgrade my proc code to work as a task manager (like top command) again 2 days of work, i could implement killing a process provided you have sufficient access rights, ya i know it has lot of flaws but i believe it is a "proof of concept" , now ask me do something in ncurses, i can do it with a bit of struggle.
next is a file manager in queue .. (long live ncurses ).

food for thought: try "tpp" the ncurses based based presentation program, ultimate, so decided to torture people with "tpp"  (available in ubuntu/debian repos)

Blogged with Flock

Friday, November 2, 2007

MFC

MFC project problem statement is out...
in simple words identify a state machine which will accept the given string of alphabets (full 2 months), god only knows how to do this..        

Blogged with Flock