Friday, December 21, 2007

emacs - malloc_jumpstart() error

After upgrade to OS X Leopard (Currently 10.5.1), the default emacs version fails to start. I checked with Google, and find out how to do it.

The problem is because my emacs version is still 21.X, need to update with dumpemacs.

bash-3.2$ sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.orig
bash-3.2$ /usr/libexec/dumpemacs -V

bash-3.2$ sudo /usr/libexec/dumpemacs -d
Checking if emacs is up-to-date
emacs is not up-to-date. Needs dumping
bash-3.2$ emacs --version
GNU Emacs 22.1.1

Wednesday, December 19, 2007

cscope on windows

"cscope -bqR" failed on Windows, it does not prompt any message but when I do a search for a function with cscope, it always doesn't give me a happy message. Because my project is mainly a c++ project!!! It is confusion on Windows "-R" recusive just find c not cpp files.

I need a extra script to generate "cscope.files", then generate cscope database.

find . -name "*.cpp" -o -name "*.[ch]" > cscope.files
cscope -b -q

On linux, there is no such problems.

And I also install "" from here, it provides basic gnu tools for win32.

Tuesday, December 18, 2007

dsfoo - with vcscommand

As I check Google code, it works with vcscommand which is a vim plugin.

For Windows user, to use Google code, has to install svn first, I download "svn-1.4.3-setup.exe" for the Windows version, and it works well with my vim. (Mostly I would like to use svn on Linux or Mac platform, but I also need my vim work on Windows)

using vcscommand with vim is quite simple.

- install vcscommand to vim 7.0
- checkout dsfoo with svn (demonstrates with my previous blog)
- find help :help vcscommand, the document is great!
- :VCSLog, :VCSDiff check the log and difference, use zz to close the buffer.
- :VCSCommit -m "commit..." will commit current file in vim, quite easy!

Note vcscommand is not only work with svn, it also works with cvs, the baseline is after you checkout the source code, you can edit the source code with vim, and commit any changes in vim.

dsfoo on Google Code

Today, I found Google provides hosting for open source project, so I just create a project -- dsfoo, to host some of my programming notes, scripts and code for share in the Internet.

To check out with anonymous...

svn checkout dsfoo-read-only

Myself, to import...
$ svn import -m "import..." ./turing https://dsfoo.googlecode/svn/trunk
Adding turing/turing_first.sed
Adding turing/README.turing_first

Committed revision 2.

to checkout and checkin...

$ svn checkout dsfoo --username dsmarkchen
$ svn commit -m "update README..." dsfoo --username dsmarkchen
Sending dsfoo/README.turing_first
Transmitting file data.
Committed revision 3.

And check the log...
$ svn log ./dsfoo

Thursday, December 13, 2007

Mac - Terminal font

The default Terminal font on Mac is Monaco 10pt, but I am a little missed with the font with Linux (xorg 7.0), so I make a little search, to try some other fonts, and find the bitstream Vera Mono 10pt is quite the same with the Linux, and "bitstream-vera" is gnome's free font, so it is free for me to use. Great.

Download font to Mac is not very hard, First download the package of the font and open it which extracts the ttf file (I did it with FireFox), and with the Finder, I can open the ttf file by double click on the file itself, it brings up the font text demo with a button "install the font", so I just click on the button and it will do what it is supposed to do. Super easy!

Then with Terminal Preference, I can select the font to use, and should be enable "antialias text" (the default is disabled that makes the monospaced font ugly), and if I choose black as background, I have to change opacity to 100% as well.

Friday, December 7, 2007

switch to vi

It's been a big decision to switch to vi. I have been using emacs for 10 years, it helps me on all the platforms from Windows, Linux to Mac OS X. Emacs lisp is such a powerful language which makes emacs so extensible. I would be miss the use of calender and diary, eshell, and xcscope with emacs.

Switching does not mean emacs is bad, may be I will change back to emacs if failed on vi, it's more like the personal taste. As I learned in these days, cscope, sed, the LaunchBar instead of QuickSilver, I feel I am more fond of "efficiency" instead of beauty.

I still didn't totally change to vi because of the gap of learning vi. Here is some notes I would like to share.

1. open file in vim. I learn vim from tutor, it shows :r to read file content to current file buffer, but did not show me how to open a file to a buffer compared with emacs's ctrl-x ctrl-f command. Here is the result :e with a file name will open the file.

2. text column. As the first experience, I enter some text, but find a line is more than 80 charactors if I don't hit cr to change to a new line, and it is a little annoying. Here is the result :set tw=80 will set textwidth to 80.

3. vimrc. Where is the location of vimrc? It is different on all the platforms, to find it the best way is use :version. In windows, it $VIM/.vimrc, on Linux it is ~/.vim/.vimrc, while on mac os x, it is "~/.vimrc".

4. The insert mode and the normal mode. Still a long way to get used to the normal mode, why the default is set to the normal mode instead of the insert mode? Also learning key strokes on normal mode, for instance, y is for copy, p is for paste, d is for delete and / for search, blah blah.

Monday, December 3, 2007

gnu sed on mac

I found the default sed tool on my MacBook is a bsd version instead of the gnu version, and my Turing machine script can not run with the bsd sed:-(, there are too many differences, so I have to build gnu sed on my Mac.

First download the source code from here, currently I am using the version 4.1.4, and 4.1.5 is broken for "install_sh" dependency.

Build sed with:

./configure --prefix=/opt/markc
sudo make install

Then sed is ready to use, but make sure the path /opt/markc/bin is in PATH environment.

Turing's Very First Example (with sed)

I have fun with sed and Turing Machine. It is pleasure to digg into sed, to find out the powerful features by sed. To me, sed is not just a tool for string find and replacement, but also Turing-Complete, that means sed is programable, the best way to prove it is to construct a Turing Machine. What I choose here is Turing's very first example by Alan Turing, so I can learn Turing Theory.

The following is my coding with seds, I implement the 4 state (b c e f) table, and use "_" to identify the head position, "$" to identify the end of tap cells and "*" for blank symbols on the tap.

# Turing's very first example

# check input
/^_\?[\*]*$/! b error

# start from first

# b blank P0,R c
: b
s/^/b /

/_/ {
# write 0

# move right

/0\$$/ b H

b c
b error

: c
s/^/c /

/_/ {
# print blank
s/_/ /
# right
s/ \*/ _/

/ \$$/ b H
b e
b error

: e
s/^/e /

/_/ {
# print one
# turn right

/1\$$/ b H
b f
b error

: f

s/^/f /

/_/ {
# print blank
s/_/ /
# right

s/ \*/ _/

/ \$$/ b H
b b
b error

: error
s/^/error with turing machine/

q 1

: H
s/^/= /
q 0

And the output:

# echo "********" | sed -f Turing_first.sed
b _*******$
c 0_******$
e 0 _*****$
f 0 1_****$
b 0 1 _***$
c 0 1 0_**$
e 0 1 0 _*$
f 0 1 0 1_$
= 0 1 0 1

Thursday, November 29, 2007

xbench on my macbook - 105.18

I run xbench on my macbook and got the score 105.18.

Seven steps to write a functioning Makefile

In my opinion, writing a Makefile is not simple, it sometimes can be more complicated if you want to your code compiled with different compilers, different running environments or targets, and different builds to support diffent features. A Makefile can accept shell or sed scripts, it makes the building process more advance. Today, I just want to cover the basic part of Makefile, or the parts I am using for a Makefile.

First define directory variables, you specifies this to tell `make' where is your project?

PROJECT_ROOT_DIR = /devel/src/foo

Second, specify the common compiler settings, most of my time is build for embedded target, so here is the code:

export ARCH :=arm
export CROSS_COMPILE := arm-linux-

# Include make variables (CC, etc...)

3rd, specifies the source code compileing rules, how you compile c++ or c code. The rules will make the later life easier

%.o : %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<

Fourth, is more specific compiling setting, you define CFLAGS, CXXFLAGS, or LDFLAGS, so you specify what header directory to include, you specify what library to link, you also specify "-g" for debug, and how you want the compiler post warning message etc.

CFLAGS += -I$(INCLS) -D_FOO_=1 -g

Fiveth, now you can provide the basic feature you want in the Makefile. Here is the sample:

compile: libfoo foo_bin

You want the user use "make compile" for build foo.

Sixth, specifiy all source code you build in seperate directories.

SRCS_FOO = $(SRCS_FOO_DIR)/util_arm.s \
$(SRCS_FOO_DIR)/foo_info.c \
$(SRCS_FOO_DIR)/foo_main.c $(FOO_SRC_DIR)/foo_help.c
OBJS_FOO = $(patsubst %.s,%.o, $(patsubst %.c,%.o, $(SRCS_FOO)))

OBJS_GST = $(SRCS_GST:.c=.o)

Seventh, now weave them together.

libfoo : $(OBJS_FOO) $(OBJS_GST)
$(CC) $(CFLAGS) -shared -o $ $^

For now, the Makefile is done, to add "clean" feature, is quite simple based the content from here.

Wednesday, November 28, 2007


After the close of trading on Tuesday, Marvell Technology's (nasdaq: MRVL - news - people ) reported a third-quarter loss of $6.4 million, or 1 cent per share, compared to a profit of $6 million, or 1 cent per share in the similar period a year ago.

Investors took notice, pushing Marvell's stock down 7.3%, or $1.22, to $15.43, in Wednesday morning trading.

I quote this from here.

What happens to Marvell today, I am not sure, it seems Marvell is sold to another big company, Intel? But any way the cut-off the work force is started, some on-going projects are dead.

Wednesday, November 21, 2007


I am using LaunchBar on my Mac, it is $20 for a single user, but it is worth for the cost, I see spotlight from Leopard can do the same kind of job as LaunchBar does, but I still choose LB on my everyday basis use because LaunchBar is more fast -- Actually I only use Mac at night after work.

Here is a video shows the basic usage of LaunchBar.

Here is my experience, basically I am using LB to launch applications, I can launch application from Finder Application directory, or click an application to run from the Dock but I don't want to a long list of applications in the dock, I want the dock to be simple. so I feel use LB is the best choice for me. The second thing with LB is browse the internet, I found LB remembers well bookmarks of Safari or Firefox, so if I wanna quick goes to the website I have to save the site to bookmarks of my Firefox as an example, otherwise LB will have no way to remember. But I am using delicous a lot, the hard thing for LB is it is not supported to the share society bookmarks, still did not try delicious2Safari (correct me if the name is not correct). There is some other beautiful functions by LB explained on the video, but I did not have a chance to use it.

At last, I think the experience will grows with using LB.

Tuesday, November 13, 2007

script - create package

Today I write a shell script that is used to create project package, so I can backup easily. There are two features I want the script supports, one is have a date stamp automatically generated, second in the source code directory I want to filter only c source code, for instance just have c and h file.

Here is the script:

export PROJECT_NAME=foo
export PROJECT_PATH=/devel/project
export DATESTAMP=`date +%d%b%Y`

tar czf $PROJECT_NAME-$DATESTAMP.tar.gz ./Makefile.arm-linux ./plugin/*.[ch] ./application/*.c

echo "DONE!"

Tuesday, November 6, 2007


I found this site several days ago, then try to download gstreamer from there, but guess what happened, it just contains the core of gstreamer, but without the build of the plugins, it is just a crap, I try to loggin to its forum and can not get into it. I found plugins from, but the plugins did not work with the crap streamer from the site, so I remove the crap and install slacky's gstreamer and it it works.

Today I found the following quote from this site, I recommend any slack user will never go to this site until its construction is ready !!!

** Because of the many false package requests (over 300 were incorrect), I had to clean the requests db table.PLEASE, report ONLY the packages that really have newer versions! If a package doesn't runs for you, check the dependent libraries, and download them. If it still doesn't work, use the forum to tell me what you get and why I should rebuild it. Recently I don't have much time for this site :( **

Monday, November 5, 2007

ALSA and Gstreamer on Linux

First, check alsa in the kernel or not.

/root/wiki/web # cat /proc/asound/cards
0 [AudioPCI ]: ENS1371 - Ensoniq AudioPCI
Ensoniq AudioPCI ENS1371 at 0x1400, irq 18

Second, use amixer to understand your audio device.

~/.gstreamer-0.10 # amixer info
Card default 'AudioPCI'/'Ensoniq AudioPCI ENS1371 at 0x1400, irq 18'
Mixer name : 'Cirrus Logic CS4297A rev 3'
Components : 'AC97a:43525913'
Controls : 24
Simple ctrls : 13

And the controls.

~/.gstreamer-0.10 # amixer controls
numid=1,iface=MIXER,name='Master Playback Switch'
numid=2,iface=MIXER,name='Master Playback Volume'
numid=16,iface=MIXER,name='PCM Playback Switch'
numid=17,iface=MIXER,name='PCM Playback Volume'
numid=8,iface=MIXER,name='Line Playback Switch'
numid=9,iface=MIXER,name='Line Playback Volume'
numid=10,iface=MIXER,name='CD Playback Switch'
numid=11,iface=MIXER,name='CD Playback Volume'
numid=7,iface=MIXER,name='Mic Boost (+20dB)'
numid=5,iface=MIXER,name='Mic Playback Switch'
numid=6,iface=MIXER,name='Mic Playback Volume'
numid=3,iface=MIXER,name='Phone Playback Switch'
numid=4,iface=MIXER,name='Phone Playback Volume'
numid=12,iface=MIXER,name='Video Playback Switch'
numid=13,iface=MIXER,name='Video Playback Volume'
numid=14,iface=MIXER,name='Aux Playback Switch'
numid=15,iface=MIXER,name='Aux Playback Volume'
numid=18,iface=MIXER,name='Capture Source'
numid=19,iface=MIXER,name='Capture Switch'
numid=20,iface=MIXER,name='Capture Volume'
numid=21,iface=MIXER,name='IEC958 Playback Con Mask'
numid=22,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=23,iface=MIXER,name='IEC958 Playback Default'
numid=24,iface=MIXER,name='IEC958 Playback Switch'

Then find out how to change the volume with amixer.

~/.gstreamer-0.10 # amixer cset iface=MIXER,name='Master Playback Volume' 45
numid=2,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw---,values=2,min=0,max=63,step=0
: values=45,45
~/.gstreamer-0.10 # amixer cget iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw---,values=2,min=0,max=63,step=0
: values=45,45

Then use aplay to test a stereo wav samples.

~/.gstreamer-0.10 # aplay ~/Desktop/nelly_raw_225.wav

Till now we can say alsa is ok if aplay works. Now let's play with gstreamer.
I am using gstreamer-0.10 it is the current release.

gst-launch-0.10 -v fakesrc num-buffers=8 ! fakesink
gst-launch-0.10 -v audiotestsrc ! audioconvert ! audioresample ! osssink

One import thing is use "gst-inspect | grep -i wavparse" if I want to know wavparse is ready with my gstreamer. Also directly check the xml in "~/.gstreamer-0.10" is acceptable.

Then use gstreamer to play the same wave file.

gst-launch-0.10 filesrc location=~/Desktop/nelly_raw_225.wav !
wavparse ! audioconvert ! audioresample ! osssink

Hopefully gstreamer works.

Wednesday, October 31, 2007

slackware 12 - on macbook

I install VMware fusion to my mac book, thus I can install other OS to my macbook, I am choosing slackware 12, the installation of slackware is quite simple. But to install VMWare tool is a little tricky, I never make it work before, because I don't know what to do when I see the menu item change to "cancell vmtool installation" and it hangs there forever. Now I know is just mount /dev/cdrom to /mnt/cdrom to run the install package from 'virtual' cdrom.

And to make vmtool install successfull, I have to install pam first, here is the build script:

./configure --prefix=/usr/local --sysconfdir=/etc
make install

also mkdir /etc/pam.d used by vmware tool,

cat << EOF > /etc/pam.d/vmware-authd
auth required /usr/local/lib/security/ shadow nullok
auth required /usr/local/lib/security/
account required /usr/local/lib/security/

In case there are some problems, here is the way on use vmxnet driver

cp /etc/rc.d/rc.inet1 /etc/init.d/network
cp /etc/rc.d/rc.inet1 /etc/init.d/networking

/etc/init.d/network stop
rmmod pcnet32
rmmod vmxnet
modprobe vmxnet
/etc/init.d/network start

Now it is time to enjoy vmware-toolbox!

Monday, October 29, 2007

tftp - on marvell device

My marvell device(PXA300) seems only work on static ip. I use HyperTerminal as emulator on Windows, with ifconfig, I got "", while my workstation ip is, and my vmware Fedora Core 5 is I don't know how to connect the device to my linux host, but here is how it works on my workstation.

- I change my workstation ip to "", gateway to ""
- Then on HyperTerminal, I can "ping", and on workstation I can "ping"
- On workstation(XP), I download and install tftp server. (Let google help to find one)
- Setup tftp, that is, start or stop tftp server, I would say my tftp server is local.

- on HyperTerminal:

tftp -p -r blah (send blah to workstation)
tftp -g -r clock.txt (get clock.txt from workstation)

Friday, October 26, 2007

cscope - setup

Here is the setting in my .emacs

(require 'xcscope)
(setq cscope-do-not-update-database t)
(setq cscope-initial-directory "/path/of/src")

(define-key global-map [(ctrl f3)] 'cscope-set-initial-directory)
(define-key global-map [(ctrl f4)] 'cscope-unset-initial-directory)
(define-key global-map [(ctrl f5)] 'cscope-find-this-symbol)
(define-key global-map [(ctrl f6)] 'cscope-find-global-definition)
(define-key global-map [(ctrl f7)]
(define-key global-map [(ctrl f8)] 'cscope-pop-mark)
(define-key global-map [(ctrl f9)] 'cscope-next-symbol)
(define-key global-map [(ctrl f10)] 'cscope-next-file)
(define-key global-map [(ctrl f11)] 'cscope-prev-symbol)
(define-key global-map [(ctrl f12)] 'cscope-prev-file)
(define-key global-map [(meta f9)] 'cscope-display-buffer)
(define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)

Common Lisp - startup

1 Pick up a Lisp implementation.

- sbcl (my current choice)
- OpenMCL, but I am not sure OpenMCL is dieing or NOT (I would like to give it a try on my MacBook.)

2 Setup development

- slime (always using the cvs version, from Marco's slime movie.
- Emacs (I would choose carbon Emacs instead of aquamacs, build Emacs from cvs is also an option, but I got a failure, is that a bug in current development version)

3 Tutorial

- slime movie, rich on coding and debugging with slime, also with Emacs tricks I never know!
- Practial Common Lisp (suggest by David Steuber)
- ANSI Common Lisp by Paul Graham (I own this book)

4 Community

- usenet comp.lang.lisp
- #lisp on

5 Where to start next

- time (1 or 2 hours quite time on MacBook)
- starter project (programming on lisp - algorithm first Red black tree)

Wednesday, October 24, 2007

VMWare - allocate disk space

Today I need to add another free disk for my new project, and my previous blog still works. Here is the steps, I am writing to create a new scsi virtual disk.

1. use vmware workstation to create a new disk 8G, and allocate spaces as well.

2. Start Fedora Core 5, run a terminal.

3. "fdisk -l /dev/sdc" to list the hard disk information, here there is no sdc1 sdc2 etc.

4. "fdisk /dev/sdc" to create a new primary disk with "n", use the all space for sdc1.

5. "mkfs.ext3 /dev/sdc1" to format the disk to ext3 format.

6. edit /etc/fstab, add a line "/dev/sdc1 /opt/marvell ext3 defaults 0 2".

7. Then I can mount /dev/sdc1 by "mount /dev/sdc1", but make sure the empty directory /opt/marvell is created first.

8. use "df" to check.

Saturday, October 20, 2007

New MacBook

I don't want to wait 6 days for Leopard release, so last night I head to futureshop to buy a new MacBook which is 2.16GHz Due Core and 1G Memory. The new one is great, its LCD is the best compared to my previous used laptops, my first ibook's LCD is a tragedy I think.
I have installed and played a lot on my MacBook, Firefox, LaunchBar, MacPorts, Emacs. Now I am maily working on to make Common Lisp on Mac OSX.

Friday, October 19, 2007


I found my time is wrong on my FC5. I run "date" and get the following result while I am in October.

Sat Sep 29 07:19:00 EDT 2007

Also I find EDT is incorrect which stand for East Daylight Time. So the first thing for me is to change time zone. I use "timeconfig" to select "America|Edmenton" for Mount Daylight time.

Then is change date, the second command save the time to hardware.

date 10190953
hwclock --utc --systohc

Tuesday, October 16, 2007

Mac OS X Leopard on Oct 26

Yesterday I make up my mind to wait for Leopard, today I check the apple's online web store, and find that it is updated, the great news is Oct 26 it will be released, in about 2 weeks! Originally I thought it would be Oct 31, because of a mac guy's point -- it is said to released at October, but doesn't mean Oct 1 or Oct 2, most likely it could be on Oct 31. Now the question to me is how long I can see it with a new MacBook on a store of FutureShop or BestBuy. At Oct 27?

Monday, October 15, 2007

mac os X - Leopard

I am a huge fan of Mac laptops, and I am so missed my ibook. The only thing I can do is to buy a new one, a 13 inches MacBook should fit my need. I almost bought one from Staple yesterday, it sells the 2.16GHz white laptop only for 1254 Bucks, the same prize as the 2.0GHz one, maybe it is a mistake. But I checked with the sales, there are only demo left in Calgary, no stocks for this city:-( Then today I found mac os X - Leopard will be unveil in this month - October, so I think I should wait to the end of the month or the early of next month, to buy a MacBook with Leopard. So be patient, just wait.

Thursday, October 11, 2007


I find Zamzar, a online PDF converter, today. And tried it with my PDF file, for PDF can not be modified by my co-worker, so I convert it to word doc format, it is good. Better than another trialed version converter I download to my PC. The only problem is I have to wait a little while (30-minutes) to let Zamzar inform me by email. I suggest Zamzar for its great quality.

Tuesday, October 9, 2007


Trolltech is an amazing company which produces a lot of interesting staff, Qt, KDE, Qtopia, Greenphone etc. It did contribution to the Free Software world, but it also make profits by commercial license fees. I don't know the opinion of RMS to Trolltech, but I know he is against Lessor GPL. I have a mixing feeling to Trolltech. I'm stand on GNU side in spirit, but make a living on GNU's opposite side.

Can you agree "Keep Linux free, use KDE!"? Myself does not use KDE. KDE is the default x window manager by Slackware, and I just find there are many LGPL packages with KDElibs, here is a reference.

I noticed a news related to Trolltech today, that is, it will make Qtopia Phone Free. Is that true? and When? Because when I worked on Qtopia Phone several month ago, I was with a commercial version.

Friday, October 5, 2007


Con Kolivas, or known as -ck which is his kernel patch's identity. He is a Linux kernel patcher for sure. Visit here for his home page on kernel patches. But he is quit what he has been doing. Why? Here is an interview that you must read.

As a Linux user, I know there are a lot of code monkey, they love programming, so Linux is just a perfect platform for them, there are always new devices in the market, new software that brings solutions on specific area, and new bugs that are found to be fixed, ..., so all the code monkey can do is coding, coding and coding, and thus what I am doing is install, install and install. Some times I make my own customized change on my thinkpad because the software I installed is still not very good on my slackware. iMac makes life easier for me, but Linux brings challenge to me -- that is what I thought. I seems choose the later in my life.

CPU performance is now not a big problem since the hardware has been upgrading for decades. To me, on audio area, it still could be causing problems on mobile devices, because the processor on mobile device is not as powerful as on PC, and sound is special time restrict, for instance, you have to fill 1764 bytes buffer in 20ms for sound rate 22050, stereo audio. CPU usage is important measurements, so if you use 10ms to fill the buffer, the usage of CPU is 50%.

I like to get in deep, to know audio, to know kernel... I read books on operating systems, on learning the Linux source code, on configure, build and install the kernel, but I never be a patcher. I may know how to write a module, and get it run in the kernel mode, but usually I don't have to build a device driver from scratch, so I am not "certain". There are a lot that need to be learn.

Although it is pity to see "-ck" gone,
To be or not to be, that's a question. (Shakespeare)
but it is good to see what he brings to us.

Monday, October 1, 2007

cweb - the way to coding

I found Knuth's image here.

I think I learned 3 things from Knuth. One, life is too short; Second, code can be beautiful; Third, math is for God?

CWEB is developed by Knuth & Levy. I am using CWEB again in my job. Basically I don't have a design for what I am doing, and I am using C language to solve my problems, then I can use CWEB. The good for using CWEB is -- code is always followed by my thoughts, so the Tex part of CWEB is my thoughts, and Code part is what I would sent to the compiler. What amazing me is my current work is mixing the channel of sound in a mixer, while in coding CWEB acts as a mixer on code and thoughts.

There are two other things I would mention with CWEB. One is doxygen, I didn't use it for my design. Doxygen is a wonderful tool good at on showing source code design. I use it a lot in my work. But with CWEB I can see the progress on the design and solving my problems, just with C language.

The second thing I want to mention is Wiki, I use wiki a lot, because I want to document what I learned. Wiki is a fast way to take notes. I think CWEB, Doxygen and Wiki make sense to me, because my way of coding is more like documenting it well. Documenting gives me the sense of solving problems, and also for reference.

Wednesday, September 19, 2007

fvwm - newbie for the years

I find myself newbie on many things such as cvs, fvwm even I use them for a long times.
On Fvwm, although most people use gnome or kde, but I am still get it a try. I like it simple, not cost too much memory. In spare time, I am fiddling into FVWM, and at last I figure out the set up of "micro GUI" decor.

Tuesday, September 11, 2007


I have a long history of using CVS, but I am still not an expert on using it. Here is a great link , it provides several types of format on learning cvs. I am using the "info" one.

1. First set CVSROOT. I use shellscript:

export CVSROOT=""

2. login "cvs login "

3. import my package

Here I make a mistake. my package is /devel/src/myproj, but I am in /devel/src, then do an import, it will import everything in /devel/src to myproj. :-(

4. Remove directories and files

cd dir
rm file1 file2
cd ..
cvs remove dir
cvs commit -m " message remove xxx"

5. Add myproj

cvs add myproject

6. check out and update and release
for check out and update, use "-P" option to avoid the empty directories.
"cvs release -d project" will end use of it!

Wednesday, August 29, 2007

arm-linux : struct alignment

The following code examine arm structure....

#include < stdio.h >

#define PACKED __attribute__((packed))

typedef struct struct_Foo
char c;
int r;
long f;

typedef struct struct_Foo2
char c;
int r;
long f;
} FOO2;

int main(int argc, char* argv[])
printf ("Test arm...\n");
printf (" char : %2d\n", sizeof(char));
printf (" int : %2d\n", sizeof(int));
printf (" long : %2d\n", sizeof(long));
printf (" foo : %2d\n", sizeof(FOO));
printf (" foo2 : %2d\n", sizeof(FOO2));

and my Makefile:

# where is my tool chains for arm
BLD_TOOL_VER = gcc-4.1.1-glibc-2.3.6
BLD_PREFIX= /opt/toolchains/greenphone/$(BLD_TOOL_VER)

# tools... I am using

CPP = $(CC) -E

CFLAGS = -x c

$(CC) $(CFLAGS) -o test test.c


int : 4
long : 4
foo : 9
foo2 : 12

Wednesday, August 22, 2007

Book - The C Programming Language

Write a post is different then write a program, if you have nothing intested to say, be quiet. That is a rule in programming on Unix. But for write a post, I don't have to follow the rule when i don't have any interesting things to say.

I am talking about the book "The C Programming Book" by KR. Despite the high price, I bought it from Chapters. Is that good value for me? yes, I think so, a C programmer need to have such a book. C language is not too hard to follow or learn, and this book is 270 pages including the index. I have already grasp the C language, so I don't learn the language from this book. But the point is, I want to know how C inventer think about C language, how they use it, it is interested to me, so this book give me the idea.

C "wears well as one's experience with it grows".

There are several points I want to confess:

1. C language and Unix. C is invented for programming on Unix, so unix is C's target, especailly the C standard library contains the interface to Unix OS. To use a language, understand well about the target is one of the keys. Note the book does not talk about the OS, it focus on Lanuage its self.

2. Algorithm and Data structures. They are important but, the book does not cover these two area, although it has code to implement fast search. Still the focus is the language itself.

3. The way to learn a lanuage, is to write programs. This book contains a lot of asignments, to modify code, or write code with what it present. We are be certain when we write programs with the language.

4. The auther write the book on the stand of the user point, so it is not top down, but on the same level as the user.

Saturday, August 18, 2007

slackware 12 - a little update on thinkpad r61i

The past week digging into thinkpad is not easy for me --

The first problem I met is the audio did not work, I don't know when it started to mute, after do a lot of research, even reinstall the whole system--. Right now the audio works on my thinkpad, but thanks people in the internet, they have got the same trouble, I did know the mixer problem, and only volume up button works, the mute and volume down button don't work.

And I build the latest linux kernel, right now I am using the default IEEE80211 module provided by the kernel, the 1.2.17 version seems can not build for the new kernel. And there is still no ipw3945 in this kernel. But my ipw3945 -1.2.1 works with the module, so I am OK using the wireless.

Still in learning slackware 12 and my new laptop.

Thursday, August 16, 2007

gdb on arm-linux

It is a little different to debug an application on arm-linux.

First, start gdbserver from the device, 3230 is any port number that is not used by the network.

gdbserver localhost:3230 ./helloworld

Second, start arm-linux-debug from the host,

arm-linux-gdb ./helloworld
target remote
b main

Here b identify set break point, and c identify continue, they are gdb commands.

Right now, I am debugging without emacs, still hope to configure emacs to support embedded debugging.

Wednesday, August 15, 2007

sed - basic uses

Sed is very useful.

First sample, the most basic use, find a string and replace it.
I can used to to access my bash script.

#!/bin/sed -f

# at the end of the file
# add comments
$ {
# author mark.chen \
# date 2007 \
# end

and my script

#! /bin/bash

export MIDIFILE=/root/Desktop/nelly.mid
export PLAYER=/usr/local/RealPlayer


Second, "dos2unix.sed". It may not perfect, I am still learning sed, but I used it remove "^M" or 0x0d from code. The use is "dos2unix.sed a.c > a_2.c", if the output is the same as the input, it may not work, so make sure the output is different

#! /bin/sed -f


Tuesday, August 14, 2007

make - patsubst

Qestions: OBJS_GROUP and OBJS_GROUP2 are the same?

Here is the Makefile:

SRCS_FOO = foo1.cpp foo2.cpp
SRCS_BAR = bar.s
OBJS_FOO = $(SRCS_FOO:.cpp=.o)
OBJS_BAR = $(SRCS_BAR:.s=.o)
OBJS_GROUP = $(patsubst %.s,%.o, $(patsubst %.cpp,%.o, $(SRCS_GRP)))
OBJS_GROUP2 = $(patsubst %.s, %.o, $(SRCS_GRP:.cpp=.o))
@echo "objs list..." $(OBJS_GROUP)
@echo "objs list..." $(OBJS_GROUP2)
@echo "foos list..." $(OBJS_FOO)
@echo "bars list..." $(OBJS_BAR)

Answer: both generates "foo1.o foo2.o bar.o".

Saturday, August 11, 2007

Lenovo thinkpad R61i - install and configuration with slackware 12.0

- install slackware 12

Simple, I still do the same as I first use slackware 3 in 1996, I can not remember the exact year.

- configuration

audio : alsamixer and alsactl store
video : use default xorg.conf change resolution to 1280x800
user account: adduser markc
choose windows: kde as default.

also, to build linux kernel and I need...

# chown -R markc:root /usr/src

- setup wireless with ipw3945

That's a big story, I spent several night on it experience failure and success, another failure and another success. I am using linux kernel 2.6.21-5 from slackware 12.0 with the following packages:


They are important, because it fails with ieee80211-1.2.18 and ipw3945-1.2.2.

1 with ieee80211, "tar, make, make install"
2 with ipw3945, "tar, make, make install, depmod"
3 with ipw3945-ucode, copy the ucode file to /lib/firmware.
4 with ipw3945d, copy ipw3945d at x86 to /sbin
5 Now goto ipw3945: do ./load debug=0,
or, modprobe ipw3945 if there is no ieee80211 and ipw3945 installed.
6 "/sbin/ipw3945d &"
7 "wpa_supplicant -Dwext -ieth1 -c /etc/wpa_supplicant.config -B"
8 dhcpcd eth1
9 ping, happly to get successful response
10 set startup script

modprobe ipw3945

in my /etc/rc.d/rc.local

and /etc/rc.d/rc.inet1.conf

use_dhcp[1] to "yes" instead of use_dhcp[0]

- setup ACPI

The default ACPI not works on the thinkpad, the only way to fix it is to rebuild the kernel.
Here is my current setting

# ACPI (Advanced Configuration and Power Interface) Support
# CONFIG_ACPI_ASUS is not set
# CONFIG_ACPI_DEBUG is not set
# CONFIG_ACPI_SBS is not set

After rebuild the kernel, ACPI at last works, but I found the following problem.

~ # dmesg | grep 3945
ipw3945: Intel(R) PRO/Wireless 3945 Network Connection driver for Linux, 1.2.1d
ipw3945: Copyright(c) 2003-2006 Intel Corporation
ipw3945: Detected Intel PRO/Wireless 3945ABG Network Connection
ipw3945: ipw3945.ucode load failed: Reason -2
ipw3945: Could not read microcode: -2
ipw3945: probe of 0000:03:00.0 failed with error -2
~ #

So I still prefer to use my download wireless packages that I have configured before, so I did an another reconfiguration on the wireless thing to make it work. BTW, in building linux kernel, the wireless device driver may have failures, I fix it by reconfigure linux kernel, such as don't include ipw2200 etc. Build a linux kernel is most easy thing for a programmer.

At last the main things works: video card with 1200x800mode, ACPI can show battery usage, and wireless network, audio can play music.

I did not test the other things such as print, fax, cd burner, usb connection, etc.

At last, I want to thank slackware, it is a wonderful distribution, not like ubuntu and fedora they have so many people and efforts on them but still not excellent, while slackware is just simply make things done.

Wednesday, August 8, 2007

Lenovo thinkpad R61i - slackware 12.0

My new laptop was arrived to my home yesterday. I bought it from compusmart, and it is about a thousand bucks but with great performance. Detail information can be found here.

I decided to give Slackware 12 the first try, I have to say slackware runs great on my new laptop. eth0, audio and video (vesa) works very well. For audio, I have to use alsamixer to change the mute settings, and use "alsactl store" to save, the same as my old 130 thinkpad. And for video, the default vesa works on 1024x768 mode, I am quite happy with that, ctrl-atl-backsapce works, I feel I can use the laptop do things.

I also tried to configure wireless network and download the drivers to build, and tried "X -configure" for 1280x800 mode, but there is some problem, for the wireless, maybe I have to rebuild the kernel. and for the video card, the ctrl-alt-backspace still don't work.

Wednesday, August 1, 2007

slackware 12.0 - siliconmotion driver downgrade

Yesterday, I went back to download the old version of siliconmotion driver 1.3.1 and built it with my current xorg version for a test. The mouse pointer shows ok -- not the 3 mouse pointer. But it still failed on ctl-alt-backspace. Where is the problem?

Tuesday, July 31, 2007

slackware 12.0 - fvwm, siliconmotion

I did not leave slackware. I downloaded the latest version of FVWM sourcecode, built and gave it an install. Now every thing is fine with FVWM.

Then I spent my rest time digging into the xorg configuration. Slackware did not use the latest FVWM but contains the latest xorg and it broken with my siliconmotion LynxEM+. I tried with a basic VGA driver, the ctrl-alt-backspace worked. With siliconmotion driver,

(II) LoadModule: "siliconmotion"
(II) Loading /usr/lib/xorg/modules/drivers//
(II) Module siliconmotion: vendor="X.Org Foundation"
compiled for, module version = 1.4.1
Module class: X.Org Video Driver
ABI class: X.Org Video Driver, version 1.1

(II) LoadModule: "vgahw"
(II) Loading /usr/lib/xorg/modules//
(II) Module vgahw: vendor="X.Org Foundation"
compiled for 1.3.0, module version = 0.1.0
ABI class: X.Org Video Driver, version 1.2
(**) Silicon MotionDepth 16, (--) framebuffer bpp 16
(==) Silicon MotionRGB weight 565
(==) Silicon MotionDefault visual is TrueColor
(**) Silicon MotionOption "NoAccel" "True"
(**) Silicon MotionOption "HWCursor" "False"
(**) Silicon MotionOption "UseBIOS" "False"
(**) Silicon MotionOption: NoAccel - Acceleration disabled
(**) Silicon MotionUsing Software Cursor
(**) Silicon MotionOption: UseBIOS disabled.

As you can see, I disabled accelerator and UseBios options.

And I check packages, here is some difference:

xorg-server 1.0.1 (X11R6 X server)
I think X11R6 is not correct it should be 7.0.0 as I dumped by Xorg.0.log

X Window System Version 7.0.0
Release Date: 21 December 2005
X Protocol Version 11, Revision 0, Release 7.0
Build Operating System:Linux 2.6.9-22.18.bz155725.ELsmp i686Red Hat, Inc.

Install log (Fc5)
Installing xorg-x11-server-Xorg-1.0.1-8.i386.
nstalling xorg-x11-drv-mouse-1.0.4-1.i386.
Installing xorg-x11-drv-siliconmotion-
Installing libXcursor-
Installing xorg-x11-drivers-7.0-2.i386.

X Window System Version 1.3.0
(II) Loading /usr/lib/xorg/modules/extensions//
(II) Module dri: vendor="X.Org Foundation"
compiled for 1.3.0, module version = 1.0.0
ABI class: X.Org Server Extension, version 0.3

Xorg web site

7.0 [ ] xf86-video-siliconmotion-X11R7.0-

7.1 xf86-input-mouse-X11R7.1-1.1.0.tar.gz

7.2 xorg-server-X11R7.2-1.2.0.tar.gz


On my FC5, the version is use 7.0 but it still use the directory /usr/X11R6 not /usr/X11R7.
XCURSOR -> X11/Xcursor/Xcursor.h

I just don't know I can build the old version 7.0 on Slackware.

Monday, July 30, 2007

linux distro - which one I will choose?

I am in the bind of choosing a linux distro -- Ubuntu, Slackware or Fedora. It seems Ubuntu always failed to me, I tried to install Ubuntu to my thinkpad 130 which is of i1171, but I always failed on harddisk problems, I use the latest vesion 7.04, I don't know why grub-install always failed. and I am very dislike the start of X windows process through CD, that is toooo slow. And from the Web I see some people have some issues with this type of thinkpad especially for the current version - 7.04.

I can install Slackware on my thinkpad. The audio device need to re-configure with ALSA utilities, that's not big deal. There is one problem I still can not figure out, that is when I configure the xorg.conf, the ctrl-alt-backspace key will bring me a blank screen, it never return, the only way to get out of it, is hit ctrl-alt-delete to reboot. Should I set the start level at /etc/inittab to 4 instead of 3. I check /var/log/Xorg.0.log, the only problem seems DRI failed. Another issue is the fvwm setup, my workable fvwm2rc will not work in this version Slackware 12, the default fvwm in slackware is version 2.4.20(or 21), so I have to reconfigure my fvwm2rc or update it. Then is the issue that may not be a problem for an experienced linux user, I don't like the pkgtool which does not support dependences, the user will take the responsiblity.

Fedora Core 5 is installed on my working machine, it works fine and I never have a problem with it. And it also works fine on my thinkpad. The main reason to choose FC5 is Yum, which compared to pkgtool on slackware, it checks package dependences. I feel Yum is quite suit to me. With yum, FC5 find the most update package for me, for example, the fvwm downloaded by yum is "2.5.21". There could be network problem with one site, but yum can goes to the other site silently. Another reason is I like some scripts in FC5 - they are "system-config-xxxx", I can use these scripts configure my hard ware easyily.

The current version of Fedora is 7, I did not have a chance to use it.

As a result, the debian Ubuntu is beautiful, but I may not use it currently. Slackware is good for learning linux, but it is not friendly to a user, the user will take care too much things which may add a lot of pain. Fedora core 5, is quite suit to me, if the yum and system-config-xxxx work all the time.

The story is not end. Shake said "To be or not to be, that's a question". Slackware bring me both pains and pleasure. For FVWM, I can download fvwm 2.5.21 which supports "decor", build and install the new fvwm will solve my fvwm2rc problem I think. but it is not very easy to build xorg the x server. Even on FC5, will it be Ok if I am using a thinkpad R61?

Will I use Slackware or FC5? That is a problem of Linux.

Thursday, July 26, 2007

slackware - audio config on thinkpad 130

Yesterday I have successfully made audio working with slackware 12 on my thinkpad. When install, I did not select arts (lib), even I don't install most components of KDE,because I would like my thinkpad running with FVWM2. The important thing is I have to choose to install alsa components to the thinkpad, otherwise the audio would not work. After installation, the audio does not work, so I have to do some extra work:

1 runs "alsaconf" to select snd-intel8x0 which is detected by alsa.
2 check the result with "aplay -l" and "aplay sound_sample.wav"
3 runs "alsactl store" to save.

The following is the dump I got from FC5. The slackware will be the same but using some other things like "/etc/modprobe.d" blah blah.

------- lspci --------
00:00.0 Host bridge: Intel Corporation 82440MX Host Bridge (rev 01)
00:00.1 Multimedia audio controller: Intel Corporation 82440MX AC'97 Audio Controller
00:00.2 Modem: Intel Corporation 82440MX AC'97 Modem Controller
00:02.0 VGA compatible controller: Silicon Motion, Inc. SM712 LynxEM+ (rev a0)
00:03.0 CardBus bridge: O2 Micro, Inc. OZ6812 CardBus Controller (rev 05)
00:06.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 08)
00:07.0 ISA bridge: Intel Corporation 82440MX ISA Bridge (rev 01)
00:07.1 IDE interface: Intel Corporation 82440MX EIDE Controller
00:07.2 USB Controller: Intel Corporation 82440MX USB Universal Host Controller
00:07.3 Bridge: Intel Corporation 82440MX Power Management Controller

------- lsmod --------
Module Size Used by
ppdev 8645 0
autofs4 19013 1
hidp 15937 2
rfcomm 34517 0
l2cap 23617 10 hidp,rfcomm
bluetooth 44069 5 hidp,rfcomm,l2cap
sunrpc 136573 1
video 14917 0
button 6609 0
battery 9285 0
ac 4933 0
ipv6 225569 12
lp 12297 0
parport_pc 25445 1
parport 34313 3 ppdev,lp,parport_pc
nvram 8393 0
uhci_hcd 28881 0
snd_intel8x0m 16077 0
snd_intel8x0 30301 1
snd_ac97_codec 83937 2 snd_intel8x0m,snd_intel8x0
snd_ac97_bus 2497 1 snd_ac97_codec
snd_seq_dummy 3781 0
snd_seq_oss 28993 0
snd_seq_midi_event 7105 1 snd_seq_oss
snd_seq 47153 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_seq_device 8909 3 snd_seq_dummy,snd_seq_oss,snd_seq
snd_pcm_oss 45009 0
snd_mixer_oss 16449 1 snd_pcm_oss
i2c_piix4 8529 0
snd_pcm 76869 4 snd_intel8x0m,snd_intel8x0,snd_ac97_codec,snd_pcm_oss
i2c_core 20673 1 i2c_piix4
snd_timer 22597 2 snd_seq,snd_pcm
snd 50501 12 snd_intel8x0m,snd_intel8x0,snd_ac97_codec,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer
soundcore 9377 1 snd
e100 33093 0
snd_page_alloc 10441 3 snd_intel8x0m,snd_intel8x0,snd_pcm
mii 5313 1 e100
dm_snapshot 16237 0
dm_zero 2241 0
dm_mirror 19985 0
dm_mod 50521 6 dm_snapshot,dm_zero,dm_mirror
ext3 116809 2
jbd 53077 1 ext3
------- /etc/modprobe.conf --------
alias eth0 e100
alias snd-card-0 snd-intel8x0
options snd-card-0 index=0
options snd-intel8x0 index=0
remove snd-intel8x0 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-intel8x0

------- /etc/asound.conf --------

------- aplay -l --------
**** List of PLAYBACK Hardware Devices ****
card 0: I440MX [Intel 440MX], device 0: Intel ICH [Intel 440MX]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Modem [Intel 440MX Modem], device 0: Intel ICH - Modem [Intel 440MX Modem - Modem]
Subdevices: 1/1
Subdevice #0: subdevice #0

Tuesday, July 24, 2007

slackware & ubuntu - a little update

Yesterday, I continue the setup with Slackware, the new thing for me is xorgcfg which generate xorg config file, I can use my xorg config file from FC5, so it is not too hard for me to config X window. The second thing is the audio setup, the artds sends failure every time I restart the sound service, and what is artds? I don't know. I don't know what is wrong with my audio setup. I have to figure out way with FC5. Slackware is good for learnning linux, because there is something broken.

And another thing I have tied yesterday was ubuntu, ubuntu 7.04 only contains one cd that is very good, and Ubuntu is very impressive in the GUI, the desktop is so wonderful, it is as good as Windows. I thought linux is not as good as Windows in the general opinion, it has a lot lot of bugs in its code (I mean system code) compared to Windows, the good thing is the architecture is simple, but it is so simple not as NT which is carefully designed. Linux is not designed while NT is carefully designed.

In the Linux world, what I can believe? gcc, make, emacs, gdb, cscope. There are a lot of tools that were built with UNIX philosophy. And on GUI, there are gnome and KDE, now gnome seems also became stable then before. I believe C, but not C++. Maybe a linux devloper that don't use debug tools, they found bug thorough code review? gdb is not very good I think, especially in C++, cscope is also not good at C++. So I would not use C++ myself in linux world. It is unbelievable to see Qt in the Linux world.

Linux for me is a great place to learn programming. For example I learn python to configure my own FVWM.

Monday, July 23, 2007


Yesterday as Sunday, I spent all my day on the download and install of slackware, all the 6CD need to be download, and I also experience burning failure with my download using bittorrent, is that a bug in my bittorrent or record sonic? -- sometimes it report failure but it actually download completely in the termarilly folder as I checked. The six iso are in the same name (of directory) cause the problem? Maybe I have to set them to different folders manually?

The install process keep the same -- I feel the way did not change too much as I first use Slackware about six or seven years ago. For example, I use fdisk to config swap (82), and the linux disk (83), luckly I know those before, it is totally inconvenient compared with FC5.

The X setup is also a nightmare, and I did not have too much the time to do that yesterday, so I will continue setup X today.

Why I have given SlackWare another chance, should I abandoned it since FC5 was quite fit my need. Because Slckware is my first chioce when I hit to linux world? Because some people they are not abandoned it?

Thursday, July 19, 2007

Amarok -- GNU's itune

Several days ago I watched some video presented by RMS, he suggests don't buy Microsoft's, Apple's blah blah, he even mentioned itunes and ipods. Don't use them, because they are against FREE SOFTWARE's spirit. Actually I owned an iPod, and don't have a plan to buy an iPhone. I can't reject the beautiful things from Microsoft and Apple's, even my life is bind ed to Microsoft a lot -- I am a programmer. On the other hand, I respect RMS, I like GNU software such as using emacs every day. Are free software my future? I don't know, but I liked GNU software, that is the trueth, and I want to participate in GNU area, and I am quite happy currently programming with GNU tools, although my product is a commercial software with license needed. (I think that's a problem for future, I have to take steps to make things happen, I mean to be a FREE SOFTWARE programmer.)

Today, I found Amarok, which is an audio player built with KDElibs, so it can only be used by linux.

Wednesday, July 18, 2007

gdb - c++ on the virtual class

Sometimes I feel I waste a lot of time stuck in one single point. If I have a class IFoo, it is just an abstract interface, so it defines foo function but never implements it. The implementation of foo was in the concreate classes, such as CFooConcreateA and CFooConcreateB. The problem of gdb is, if I use a pointer to IFoo, as "IFoo* pFoo", gdb only reports the type of pFoo is IFoo, I have no way to get the real concreate object by pFoo, so if i do "print *pFoo", gdb will response with "incomplete type". I search the internet, read gdb manual again and again, even read gdbinit macro about QString, still no help (QString contains a 'd' to store the string data which is different than IFoo). Am I something wrong, learning gdb not enough, or there is really no way to figure it out.

The only way right now is leave it:-(

Tuesday, July 17, 2007

gdb - debug plugins with realplay

When I debug helix plugins with realplay, my old way, setting LD_PRELOAD, seemed do not work,mainly because realplay is an X windows application, and I can not go to the main entry point before load the shared "so". My new way to debug helix plugin is, run realplay externel on a shell:

export HELIX_LIBS=/usr/local/RealPlayer
/usr/local/RealPlayer/realplay.bin &
[1] 4175

the number 4175 will be the process id which will be used by gdb.

Then start gdb in emacs, "ESC-x gdb":

attach 4175

will attach the running process with gdb, then, I can set break points for my plugins.

When debugging, the main problem here is, the helix code is not available since I directly pull the builtin files from, so the `next' command will complain when there's not valid code to debug. Here is a reference from RMS gdb manual:

The next command will exit any functions we can't debug (like C library functions).

Since `next' will not work if the plugs calls a function from helix, but the other command `until' still works, the only thing is, I may not like to use this command.

Sunday, July 15, 2007

Saturday, July 14, 2007

Thinkpad 130 - install fc5

Yesterday, I made linux installed on my thinkpad 130. That's a wonderful experience, guess what, I have failed a thousand times playing my thinkpad with linux in all these years. I bought it maybe around 2000, that's 7 years and it works fine except the battery and sometimes the fans got noisy. The best is its LCD, compared to my ibook G4 which I bought last year, I have to say Apple's LCD is tooooo bad. I used to install Redhat or Debian on thinkpad but with a problem of the sound card, I just can not figure out the sound card driver, right now FC5 is totally support. Thanks FC5!

You know, my thinkpad is getting old, with CPU Celeron 600, a little bit slow compared to most computers today; only 10G harddisk I have to consider the diskspace because today's software getting bigger and bigger; and CDROM so DVD is not support.

How long will it continue its history while I use it for coding as my interest?

Friday, July 13, 2007

gdb - on shared library

I am experiencing problems when I set pending breakpoints to debug shared library. The good thing is at last I found the way for debugging even the pending breakpoints still don't work. I use the following commands:

set environment LD_PRELOAD /home/build/src/helix/debug/

to debug pcm rendering, for example.

Monday, July 9, 2007

vmware - add new disk

My vmware virtual harddisk is full, the default installation is 8gb. When I build the qtopia or helix, the disk space will be used a lot for compiling files. I found this site and followed the instruction to add my new virtual disk.

Friday, July 6, 2007

smb4k - browse share folders in the net work

smb4k is a very basic tool to browse share folder in the local network. I just learn to use it. The main problem is the setup, and it could be true that using vmware that make browsing share folders more difficult.

The following command tool help me shoot the problem.

smbclient -U markc -W QSLCGY01 -L //QSLFILE01
mount -t cifs //QSLENG04/Qt -o 'user=markc,pass=mypassword,workgroup=QSLCGY01' /mnt/Qt
smbtree --user=markc%password
/usr/bin/smb4k_mount --suid -t cifs //QSLENG04/Qt /mnt/Qt -o user=markc@QSLCGY01,password=mypassword

One benifit is -- without VMWare share folders (I still did not figure out how to share my folder to FC5), I can locate my XP directory.

There are some problems I met:
- KWallet is disabled in FC5.
- Share folders are not shown in the computer

What works to me: manual mount
Share: //QSLENG13/markc
IP: (note: not
Workgroup: QSLCGY01
And authentication user name markc and password.

Tuesday, July 3, 2007

Au - Debug with gdb

I thought I have got the idea on debugging in linux platform -- mainly using gdb, cscope in emacs. Emacs is an IDE or NOT IDE, doesn't matter, but in emacs, source code browse (open file in c-mode or c++ mode), gdb and cscope can work together to make the magic happen. Here are some tips when running gdb:

- use cscope to find the function you want to trace, then open the souce code in C/C++ mode.
- C-x [space] to set break point. (c-mode and gdb)
- "f" will bring me to where the code runs at. (gdb)
- trace the memory variables (gdb)

x/160xb 0xb7f690c8
| |\ |
| | \ |
| | \ |
| | \ |
N F U Address
Here N: repeat times,
F: display format: x for hex, s for string.
U: unit size: b for bytes, h is two bytes, w for four bytes.

(gdb) x/160xb 0xb7f690c8
0xb7f690c8: 0x8e 0x93 0xa6 0x34 0x18 0x0f 0x0f 0x17
0xb7f690d0: 0x2e 0xac 0x96 0x8e 0x8f 0x9b 0xd6 0x1e
0xb7f690d8: 0x12 0x0f 0x15 0x25 0xb9 0x99 0x8f 0x90
0xb7f690e0: 0x9b 0xca 0x1f 0x13 0x10 0x17 0x2a 0xb1
0xb7f690e8: 0x98 0x90 0x92 0x9f 0x46 0x1c 0x12 0x13
0xb7f690f0: 0x1c 0x47 0xa1 0x94 0x91 0x99 0xbb 0x25
0xb7f690f8: 0x16 0x13 0x19 0x31 0xaa 0x96 0x92 0x98
0xb7f69100: 0xb1 0x29 0x18 0x14 0x1a 0x32 0xaa 0x97
0xb7f69108: 0x93 0x9b 0xbd 0x25 0x17 0x15 0x1e 0x4d
0xb7f69110: 0xa1 0x95 0x96 0xa2 0x45 0x1d 0x16 0x19
0xb7f69118: 0x2b 0xb2 0x9a 0x95 0x9c 0xc4 0x24 0x18
0xb7f69120: 0x18 0x25 0xc3 0x9d 0x96 0x9c 0xba 0x28
0xb7f69128: 0x19 0x19 0x26 0xc3 0x9d 0x98 0x9d 0xc4
0xb7f69130: 0x26 0x1a 0x1b 0x2d 0xb4 0x9c 0x99 0xa4
0xb7f69138: 0x4c 0x1f 0x1a 0x1f 0x4a 0xa6 0x9a 0x9d
0xb7f69140: 0xb9 0x2b 0x1c 0x1d 0x2f 0xb2 0x9d 0x9c
0xb7f69148: 0xac 0x38 0x1e 0x1d 0x2b 0xbe 0x9f 0x9c
0xb7f69150: 0xaa 0x3e 0x20 0x1d 0x2b 0xbf 0xa0 0x9d
0xb7f69158: 0xad 0x3a 0x20 0x1f 0x30 0xb7 0x9f 0x9f
0xb7f69160: 0xb8 0x2f 0x1f 0x23 0x43 0xac 0x9f 0xa7

Friday, June 29, 2007

Au - rendering (cscope with helix code)

- start from the decoding function (PCM_CONVERTER_ULaw2Linear)
use cscope, I can find who call it, or it call whom.
Here I focus on the first part, who call it?

- it was CPCMAudioFormat::DecodeAudioData
go to definition

- CPCMAudioFormat is derected by CAudioFormat
so what is CAudioFormat?

- CAudioFormat is a fileformat reader, there is no "I" class related to it.
now go back to find who use CPCMAudioFormat? C-F5

- it was in datatype/wav/renderer/pcm/pcmrend.cpp
class CPCMAudioRenderer, function CreateFormatObject.
so take me to CPCMAudioRenderer(C-F7)

- datatype/wav/renderer/pcm/pub/pcmrend.h
take a close look on CPCMAudioRender
1 is it a plugin? Sure it is, GetPluginInfo will return the plugin information.

- take a look on IHXPlugin, it has two functions, GetPlugInfo, and InitPlugIn
so where is InitPlugin for CPCMAudioRender?

- IT is strange it does not have InitPlugin. !!!
Now take a look on IHXRenderer.

- Actually I take a look of CAudioRenderer, it is public directed from IHXPlugin and IHXRenderer
- it has a InitPlugin, that's why CPCMAudioRenderer does not contained it.

- It is easy to use definition of CAudioRenderer to find the implementation of InitPlugin.
Now goback to CAudioRenderer, to find what kind of function should be defined as a renderer.

- hxrendr.h GetRendererInfo, StartStream,EndStream OnHeader, OnPacket OnTimeSync etc.
so goto CPCMAudioRenderer or CAudioRenderer to find each implentation

- It is good CAudioRenderer contains a bunch of implementation such as
StartStream, EndStream etc.
So for PCM renderer, what should be implemented?

- As i read in CPCMAudioRenderer, GetRendererInfo it contains "const string" for the class.(information). CreateFormatObject to create CPCMAudioFormat
HXCreetaeInstance to create its self, and CanUpload2 (I think this one is not important)
so the main thing is what I read before "CreateFormatObject"!

- Read "SDK::coding a rendering plugin for audio", it is a little different
a. StartStream, get interface of AudioPlayer.
YES CAudioRenderer::StartStream contains it.
b. Create an AudioStream object, is it not in StartStream?
Let me find CreateAudioStream, it is in CAudioRenderer::InitAudioStream
c. InitAudioStream was call in CAudioRenderer::OnHeader, OnHeader first create format object, then create audio stream object.
d. As I read the SDK, OnHeader required channels, bits per sampel, samples per sec etc, where is it in the code?
Hey, That's HXAudioFormat, how it is set?
e. m_pAudioFormat (in CAudioRenderer) is created by CreateFormatObject, I
seems wandering here :-) Just take anothe close look on CreateFormatObject.
f. So I goback to CAudioFormat::GetAudioForamt, the convertion of
Here is the result:

HX_RESULT CAudioFormat::GetAudioFormat(HXAudioFormat& audioFmt)
audioFmt.uChannels = m_pAudioFmt->uChannels;
audioFmt.uBitsPerSample = m_pAudioFmt->uBitsPerSample;
audioFmt.ulSamplesPerSec = m_pAudioFmt->ulSamplesPerSec;
audioFmt.uMaxBlockSize = m_pAudioFmt->uMaxBlockSize;

return HXR_OK;

the up questions are figured out.

g. (the 4th on page 175) m_pAudioStream::Init with pHeader at audrend.cpp.
What is pHeader.

- Now let's go back, another question who call DecodeAudioData in
CPCMAudioFormat? (Before this question, I have digged about the creation

a It is at CAudioFormat::CreateAudioFrame, so who call this function?

b The answer is CAudioRenderer::DoAudio, up??

c Now it is here: CAudioRenderer::OnPacket

d Now I found I am digging about the 5th on page 175

- Now is the write PCM audio data, (the 6th on page 175)
a. the write was called in CAudioRenderer::WriteToAudioServices
b. CAudioRenderer::DoAudio first CreateAudioFrame, then WriteToAudioServices.
(Note here there could be multiple audio stream)

== postmortem

1. with SDK's guideline, I can use cscope to find how it was implemented in
helix source code. so cscope is a very power tool!

2. use cscope on this things: (function example)
- where is the definition of the function (here)
- who call this function (up)
- In this function, it call what functions (below)
In C++, it is a little different, usually I check the definition of the
class, it will display member functions in this class, so I can locate the
function definition

%%% csope %%%
Finding functions calling: WriteToAudioServices

Database directory: /home/build/src/cscope_d/
*** /home/build/src/helix/datatype/common/audrend/audrend.cpp:
DoAudio[1401] retVal = WriteToAudioServices(&audioData);

*** /home/build/src/helix/datatype/rm/audio/renderer/rarender.cpp:
DoAudio[1688] pnr = WriteToAudioServices(uLowest, &audioData, ulActualTimestamp);


move curser to DoAudio, type 'c', it will find functions that call DoAudio.

- right now, the problem is how to go back to WriteToAudioServerices, I need
to buffer list, or go back to class, then locate the source code to find
it, it is seems no covenient.

3. main issue: use gdb how to debug it? (the renderering plugin)

Au - the basic

Check here for the basic concept of Au. Au is quite simple audio format, it is just PCM data with compression. Below is a sound (Au format) I got for a fvwm effect sound:

00000000: 2e73 6e64 0000 0028 0000 02cf 0000 0001 .snd...(........
00000010: 0000 1f40 0000 0001 6f6e 6520 6472 6970 drip
00000020: 0000 0000 0000 0000 fefe fffe fdff fefe ................
00000030: 7e7e 7c7d 7e7e 7eff 7e7e fe7f 7efe fefe ~~|}~~~.~~..~...
00000040: fefd fdff 7ffa e4e1 5846 4556 c0ad aab0 ........XFEV....
00000050: dc30 211c 1c22 37bb a096 8f8e 9198 aa2d .0!.."7........-
00000060: 170d 0909 0d11 1bd0 9d90 8a89 8b92 a732 ...............2
00000070: 190e 0c0d 1320 ee9f 918c 8b8d 97b9 2413 ..... ........$.
00000080: 0c0c 0e17 2daf 988e 8b8d 95af 2915 0d0c ....-.......)...
00000090: 0e19 34aa 958d 8c8f 9ce9 1d10 0d0e 1427 ..4............'
000000a0: b999 8e8c 8e9b ce1f 110d 0e17 2cae 968e ............,...
000000b0: 8d92 a438 180f 0e12 1fd6 9c8f 8d90 9e4d ...8...........M
000000c0: 1b10 0e13 20ce 9c8f 8e93 a634 180f 0f17 .... ......4....
000000d0: 2eac 968e 8f9b d61e 120f 1525 b999 8f90 ...........%....
000000e0: 9bca 1f13 1017 2ab1 9890 929f 461c 1213 ......*.....F...
000000f0: 1c47 a194 9199 bb25 1613 1931 aa96 9298 .G.....%...1....
00000100: b129 1814 1a32 aa97 939b bd25 1715 1e4d .)...2.....%...M
00000110: a195 96a2 451d 1619 2bb2 9a95 9cc4 2418 ....E...+.....$.
00000120: 1825 c39d 969c ba28 1919 26c3 9d98 9dc4 .%.....(..&.....
00000130: 261a 1b2d b49c 99a4 4c1f 1a1f 4aa6 9a9d &..-....L...J...
00000140: b92b 1c1d 2fb2 9d9c ac38 1e1d 2bbe 9f9c .+../....8..+...
00000150: aa3e 201d 2bbf a09d ad3a 201f 30b7 9f9f .> .+....: .0...
00000160: b82f 1f23 43ac 9fa7 f928 202d c5a4 a2b7 ./.#C....( -....
00000170: 3322 2750 aba2 ae44 2626 3eb1 a4ac 5729 3"'P...D&&>...W)
00000180: 273b b6a6 ac5b 2a28 3eb5 a7af 4b2a 2b4c ';...[*(>...K*+L
00000190: b0a9 b93c 2a2f d9ad acd0 322c 3ebb acb7 ...<*/....2,>...
000001a0: 462d 32df afaf e133 2f4d b7af c63b 2f40 F-2....3/M...;/@
000001b0: bfaf be42 313e c6b2 bd48 333e cab4 bf48 ...B1>...H3>...H
000001c0: 3541 c7b6 c544 374a c2b8 d13e 3a5d bdbc 5A...D7J...>:]..
000001d0: 7a3c 3fda bbc5 4c3c 4ec6 bde5 4041 e3bf z< ?...L< N...@A..
000001e0: c94e 3f59 c6c2 6f41 4bd2 c1dd 4747 e7c4 .N?Y..oAK...GG..
000001f0: d14e 4779 c7ce 5547 67cb ce59 4965 cccf .NGy..UGg..YIe..
00000200: 5b4b 6acd d25a 4d75 ced9 574f efcf e353 [Kj..ZMu..WO...S
00000210: 56e0 d1ff 525f d9d7 6454 7bd6 e45a 5ce2 V...R_..dT{..Z\.
00000220: d875 5871 dae3 5e5e e7db 745b 76dd ec5e .uXq..^^..t[v..^
00000230: 66e4 e268 5ff2 e178 5f7b e1f3 6370 e5ec f..h_..x_{..cp..
00000240: 676b ebec 6a69 efeb 6f6a f2ea 746b f2ea
00000250: 776d f6ee 706e f3ee 7570 f1ef 7574 f1f3
00000260: 7277 f3fb 6f79 f37c 72fd f37a 76f6 f878 rw..oy.|r..zv..x
00000270: 7bf8 7e75 7ffa 7b7a f9fa 797f f87e 7bfe {.~u..{z..y..~{.
00000280: fc7b 7dfb 7d78 fefd 7bfd f77e 7bfd fe7c .{}.}x..{..~{..|
00000290: 7efe 7b7f fd7e 7dfc fd7d fdfd 7d7e fd7c ~.{..~}..}..}~.|
000002a0: 7cfe 7d7d fffe 7efe fd7e fefe 7d7f 7e7e |.}}..~..~..}.~~
000002b0: 7e7e 7dfe fd7e ffff 7d7e fe7d 7e7f 7e7f ~~}..~..}~.}~.~.
000002c0: 7e7d ff7f fffe fc7f fffe ff7d 7c7a 7b7d ~}.........}|z{}
000002d0: 7d7f 7e7f fdfd fdfd fdff fefe 7e7d 7d7d }.~.........~}}}
000002e0: fffe ff7f ffff 7f7d 7e7f 7f7e 7e7e ff7f .......}~..~~~..
000002f0: fffe feff ffff 7e

The file was shown in emacs hex mode. Dig into it ---

header six 32-bit words
0 2e 73 63 64 magic numbers
1 00 00 00 28 data offset: 0x28 = 40
2 00 00 02 cf data size 0x2cf = 719 (0x2f6 = 758+1 (759))
3 00 00 00 01 encodeing mu-Law, damm! what's that?
4 00 00 1f 40 sample rate 8000
5 00 00 00 01 channels 1

mu-Law ??

basiccaly used in North America, Japan while A-Law(27) used in European and
the rest of the world.

The ยต-law and A-law algorithms encode 14-bit and 13-bit signed linear PCM
samples (respectively) to logarithmic 8-bit samples. Thus, the G.711
encoder will create a 64 kbit/s bitstream for a signal sampled at 8 kHz.

14/13 --> 8bit
8khz : 8000 samples per sec
so : 8*8000 = 64kbit/s per sec !!!

decoding algorithm:

const unsigned short g_wU2L16[] = {
33280, 34308, 35336, 36364, 37393, 38421, 39449, 40477,
41505, 42534, 43562, 44590, 45618, 46647, 47675, 48703,
49474, 49988, 50503, 51017, 51531, 52045, 52559, 53073,
53587, 54101, 54616, 55130, 55644, 56158, 56672, 57186,
57572, 57829, 58086, 58343, 58600, 58857, 59114, 59371,
59628, 59885, 60142, 60399, 60656, 60913, 61171, 61428,
61620, 61749, 61877, 62006, 62134, 62263, 62392, 62520,
62649, 62777, 62906, 63034, 63163, 63291, 63420, 63548,
63645, 63709, 63773, 63838, 63902, 63966, 64030, 64095,
64159, 64223, 64287, 64352, 64416, 64480, 64544, 64609,
64657, 64689, 64721, 64753, 64785, 64818, 64850, 64882,
64914, 64946, 64978, 65010, 65042, 65075, 65107, 65139,
65163, 65179, 65195, 65211, 65227, 65243, 65259, 65275,
65291, 65308, 65324, 65340, 65356, 65372, 65388, 65404,
65416, 65424, 65432, 65440, 65448, 65456, 65464, 65472,
65480, 65488, 65496, 65504, 65512, 65520, 65528, 0,
32256, 31228, 30200, 29172, 28143, 27115, 26087, 25059,
24031, 23002, 21974, 20946, 19918, 18889, 17861, 16833,
16062, 15548, 15033, 14519, 14005, 13491, 12977, 12463,
11949, 11435, 10920, 10406, 9892, 9378, 8864, 8350,
7964, 7707, 7450, 7193, 6936, 6679, 6422, 6165,
5908, 5651, 5394, 5137, 4880, 4623, 4365, 4108,
3916, 3787, 3659, 3530, 3402, 3273, 3144, 3016,
2887, 2759, 2630, 2502, 2373, 2245, 2116, 1988,
1891, 1827, 1763, 1698, 1634, 1570, 1506, 1441,
1377, 1313, 1249, 1184, 1120, 1056, 992, 927,
879, 847, 815, 783, 751, 718, 686, 654,
622, 590, 558, 526, 494, 461, 429, 397,
373, 357, 341, 325, 309, 293, 277, 261,
245, 228, 212, 196, 180, 164, 148, 132,
120, 112, 104, 96, 88, 80, 72, 64,
56, 48, 40, 32, 24, 16, 8, 0

// from 8bit to 16 bit (PCM data)
unsigned int
PCM_CONVERTER_ULaw2Linear(unsigned char* pbSrc,unsigned short* pwDest,
unsigned int dwSampleNum)
unsigned char* pSrcEnd;

HX_ASSERT(pbSrc && pwDest);

for(pSrcEnd=pbSrc+dwSampleNum; pbSrc < pSrcEnd; pbSrc++,pwDest++)
*pwDest = PCM_CONVERTER_U_TO_L16(*pbSrc);

return dwSampleNum;

emacs - new font

Today I found Eric Raymond's fvwm2rc file, and found he use fixed font on 15, it looks good on my computer, so I change my configuration of fvwm, I also disable titles of emacs and xterm, just hope xterm is ok to be put on the right side.
Here is another view with "-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1".

Thursday, June 28, 2007

fvwm - On fedora 5 VM machine

Fvwm is my choice of window manager on linux, it seems a little obsolete at today 21 century, but I love it's simple and fast.

Here is the way to install: first "yum install fvwm", that is definitely, but you also need this package -- switchdesk, using it will avoid all the manual change of the startup scripts. Use switchdesk is super easy -- "switchdesk fvwm".

The next thing is config the desktop, I use a package from here. It does not contains a lot of stuff, farely suit my development puperpose.

Right now, the problem using the built fvwm by Fedora is, it does not include the xft, so I can only use the basic font. Otherwise, everything should be ok.

For windows managers, usually fvwm is my first choice, I also choose sawfish (on gnome) before, it seems sawfish is not updated for 2 or 3 years, is it died? I don't know.

Tuesday, June 26, 2007

vmware - hostname is minint-xxxx

I am not quite familiar with VMWare, it seems always have problems. It is strange on my FC5, the host name sometimes shows minint-blahblah, I change the setting from bridge to NAT, and it starts to use the host name defined in /etc/hosts. (NAT is used to share host's IP address)

Monday, June 25, 2007

fetchmail -- by Eric S Raymond

Raymond has written a famous book TAUP "The Art of Unix Programming", I borrowed it from library several times, I liked to read it--.

Until today, I download the source code of fetchmail, (it is a C case study in TAUP). Interesting found that fetchmail is really written by Raymond, so I see why there are a lot of samples are from fetchmail, POP3, SMTP etc, in the book (TAUP). Fetchmail is written by C and it is so neat!! As I cscope into it, the struct as "method", "query", etc, I like such nice design. When read the code, I found some routines are very long, is it a pity? But at least the whole functions or interfaces are kept light! The hard part to me is I am not going to learn the protocols (POP3, SMTP, RFCs). It is not documented in a doxygen layout although it contains a doxygen config file. Discard such things, I still think fetchmail is very good sample on C, it is great because it is coded farely "light" in C, even it deals with different protocols (RFCs).

Here is a demo in "fetchmail.h":

struct method /* describe methods for protocol state machine */
const char *name; /* protocol name */
const char *service; /* service port (unencrypted) */
const char *sslservice; /* service port (SSL) */
flag tagged; /* if true, generate & expect command tags */
flag delimited; /* if true, accept "." message delimiter */
int (*parse_response)(int, char *);
/* response_parsing function */
int (*getauth)(int, struct query *, char *);
/* authorization fetcher */
int (*getrange)(int, struct query *, const char *, int *, int *, int *);
/* get message range to fetch */
int (*getsizes)(int, int, int *);
/* get sizes of messages */
int (*getpartialsizes)(int, int, int, int *);
/* get sizes of subset of messages */
int (*is_old)(int, struct query *, int);
/* check for old message */
int (*fetch_headers)(int, struct query *, int, int *);
/* fetch header from a given message */
int (*fetch_body)(int, struct query *, int, int *);
/* fetch a given message */
int (*trail)(int, struct query *, const char *);
/* eat trailer of a message */
int (*delete_msg)(int, struct query *, int);
/* delete method */
int (*mark_seen)(int, struct query *, int);
/* mark as seen method */
int (*end_mailbox_poll)(int, struct query *);
/* end-of-mailbox processing */
int (*logout_cmd)(int, struct query *);
/* logout command */
flag retry; /* can getrange poll for new messages? */

Friday, June 22, 2007

helix - build splay for playing wav files

Actually I am building splay with eshell, here is part of my configure scripts to support helix:

(defconst helix-build-root-dir "/home/build/src/build")
(defvar helix-eshell-initilized nil)
(defun helix-eshell-mode-hook ()
(when (not helix-eshell-initilized)
(setenv "BUILD_ROOT" helix-build-root-dir)
(setenv "SYSTEM_ID" "linux-2.2-libc6-gcc32-i586")
(setenv "CVS_RSH" "ssh")
(setenv "CVSROOT" "")
(ted-add-to-list* 'exec-path (expand-file-name "bin" helix-build-root-dir))
(setenv "PATH" (markc-build-path-string exec-path))
(setq helix-eshell t)))

(add-hook 'eshell-mode-hook 'helix-eshell-mode-hook)

Using it will save me a lot of time. Then is the build, I execute "" on my eshell,
branch: hxclient_2_0_3_cayenne (I think 1_5_0 do the same way)
profile :/home/build/src/build/umakepf/helix-client-all-defines
target(s): splay

Before run the build, I would like to check out source code first, that was the menu item 11.
[11] Checkout source for selected target now

then select "[3] run:build" to run the build.

til now, you can use splay play mp3, but not wav. what to do next?

still use "" to build 2 "target"s, one is, the other is, I compared hxplay with splay, noticed that these two modules are missing.

Set Target(s) (datatype_wav_renderer_pcm)

Build Complete: Wed Jun 20 01:58:05 2007
MD5 (debug/
MD5 (debug/pcmrendlib.a)..............267039112af294a3f04ca7ec27126199
MD5 (debug/utillib.a).................e03cdbb51d2576d7172290befa3eaa1d

after the first target is done, still won't work, so I found the next:
Target(s) (datatype_group_audio)
and the result:

MD5 (debug/aiffplin.a)................54987e692a2cca90e03e5bf10107670c
MD5 (debug/amrdump)...................80a4c6179c913a6354f469ffaed1bc3e
MD5 (debug/
MD5 (debug/
MD5 (debug/
MD5 (debug/auffplin.a)................cb8e007d0cba85fa0e87a82733d247ea
MD5 (debug/aviffpln.a)................68d0fafcd0c05f647f93fb6e0c86a11b
MD5 (debug/
MD5 (debug/
MD5 (debug/
MD5 (debug/protutillib.a).............659b72f44b5f691cd3a24010413cfaab
MD5 (debug/rtsplib.a).................e82688da1e2305078911a606dcbe6a09
MD5 (debug/utillib.a).................f3eecdc4482d5ddd72529883bb396faf
MD5 (debug/wvffplin.a)................5583a00a7209d684642a65f1a4159ab9

Now I can play the wav...

/home/build/src/helix # ./debug/splay ~/Desktop/Heli44k.wav
Simpleplayer is looking for the client core at /home/build/src/helix/debug/
Common DLL path DT_Common=/home/build/src/helix/debug
Plugin path DT_Plugins=/home/build/src/helix/debug
Codec path DT_Codecs=/home/build/src/helix/debug
Can't open file: /root/.helix/HelixShared_0_0.
opening file:///root/Desktop/Heli44k.wav on player 0
Device Configured:
Sample Rate: 44100
Sample Width: 16
Num channels: 1
Block size: 4400
Device buffer size: 65536
Supports GETOSPACE: 1
Supports GETODELAY: 0
----------------clip info--------------------
========Source 0========
====File Header====
StreamCount 1
Flags 1
====Stream 0====
StreamNumber 0
MaxBitRate 705600
AvgBitRate 705600
MaxPacketSize 1764
AvgPacketSize 1764
StartTime 0
Preroll 2000
Duration 11998
BitsPerSample 16
SamplesPerSecond 44100
Channels 1
RTPPayloadType 11
TrackEndTime 11998
PostDecodeDelay 3000
MimeType audio/L16
/home/build/src/helix #

mutt - with gmail

I have heard mutt for a long time, but never got a chance to use it, because it does not support public WEB mail account, I am not in a college, why I used it? maybe I am wrong. But recently I started to use it on my Linux system, because I found it is not that bad to configure mutt with gmail. Check this site, and have mutt configured with gmail.

I am more like gamil since using it, even I found that blogger is now combined in gmail, so I created this blog, it is so easy and convenient than I expected. Since gmail can connect blogger, why I can not use mutt to write or send blogs? Maybe there are some ways to do it.

Thursday, June 21, 2007

emacs - buffer inheritence

You create a list of files that you want to be in the database and call it cscope.files. So something like: find . -name '*.[ch]' -print > cscope.files

Then you do cscope -q, it grinds for a bit and then pops up with a user interface. The user interface is a curses type thing. You can search for all of the places that foo is used. You can search for where foo is defined. You can search for where foo is assigned. These searches are extremely fast. You can also do a number of slower searches like find a string, regexp, etc.

There is a programatic interface to cscope that a number of people have hooked into emacs. In my weird case, I have the concept of buffer inheritance. This is a different concept from cscope that my cscope interface ties in to. With buffer inheritance, each buffer has a parent. So foo.c would have a parent of cscope: dog. cscope: dog is a buffer (and thus a window) that formats the output of the programatic interface to cscope. So, for example, I can search for the places that var is used. The list pops into the cscope: dog buffer. I then click on one of the lines and that file is opened and I'm placed at that line. The last bit is much like tags. But the search is much broader. The search will find any place that var is used in any of the files listed in cscope.files. If you open a file from the cscope:dog interface, then its parent is assigned to cscope:dog.

The reason for inheritance is so I can have multiple cscopes running at the same time and things stay organized. So, for example, I can have a cscope running on the version 1 code and a cscope running on the version 2 code. Clicking and searching while in a buffer from the version 1 source base will search the version 1 cscope. Clicking and searching while in a version 2 buffer will search the cscope for the version 2 code.

Other implementations of cscope.el I've seen have the concept (instead of inheritance) of a list of cscopes. All of the cscopes are searched each time. That would not work for me at all. I do support mostly and ping ponging between different versions and keeping things straight is key for me.

The user interface I have is I have Control-\ hooked to a personal-map. In the personal-map I have each of the nine or so functions that cscope can do hooked to a different key. e.g. C-\ s does a search for a variable. C-\ f does a find of the variable's definition. C-\ F will find a file. etc.

I also have these hooked up to mouse functions but I rarely use the mouse. I think, while in a buffer that has a cscope parent, I can double click on a variable and it will do a search. Double click with the different cord keys does different things: find, etc.

Oh... now the hate part. cscope when it parses the files is not doing a real parse. It can not. You get into problems with conditional compilations and needing to include header files, etc. So, it is a 90% parse (maybe 95%). It is pretty accurate but it fails at times. Also, the thing that I want is to be able to have a more precise search. For example, I want to be able to find where the field foodog of the structure henry is used. Right now, I can only find all foodog's which may be fields of any structure, variables, or globals. But alas, the truth is, this desire wells up inside of me fairly rarely. (Obviously, not often enough for me to do something about it).

I don't know what languages cscope supports. Originally it was c. It does a fairly decent job of c++. I think it has been extended but I'm not up to date with how many languages it supports. It does seem like most of the newer languages like Ruby, cscope could do a 100% parse fairly easily.

The way I was going to integrate cscope into ecb (before this discussion) was to make the names of the cscope buffers match the name of the "compile" window. I have not used ecb's compile window any yet. But, my thought is that you want the cscope window somewhat present all the time (if it is displayed at all). So, as you click around, the cscope window stays put. But, I have not used it that way yet so I may quickly decide that that is not what I want at all.

Perry Smith disclose here a very great opinion, the "buffer inheritence" in emacs, I am using xcscope, but not coding on that, so I may not be clear on how the core works in emacs. That will be a great area for me to explore emacs-lisping.

KScope (the KDE version) is doing good on linux kernel, but does not doing good on itself -- the Qt C++ language parsing. Why cscope is not doing good on C++ compared to C, I think C++ is more complex than C, usually people will only use a part of C++ as a lanuge, for Qt, it has MOC preprocessing the C++ code.

Without cscope, I am using doxygen, and I have quite a few years experence using it, usually it's more suit for C++. Maybe I have too few experience on cscope. The success of doxygen is a little bit like "WEB" from Don Knuth, it displays each small part of code very well, then with web browser's help, people can navigate code. Don knuth designed WEB originally just for layout, but found it is also good to design program with it, that is the magic of WEB. So doxygen with web browser's help is still the best practical way to browse source code (c,c++) right now for me.

But still cscope is impressed to me since it is so fast to search a symbol, I think it is still a very powerful tool with simple goals. The magic will be how emacs use it.

Wednesday, June 20, 2007

kscope - download and build

The current version of KScope is 1.5.2, I download it (kscope-1.5.2.tar.gz) from, I also tried the cvs way, but it seems broken to me, so I thought the cvs version was in development.

On FC5, I have to install KDE staff with Qt to make the configure script happily go through.

yum install kdelibs-devel kdebase

Then is make command to build the kscope, but there is a failure that need to be fixed, here is the fix.
cd /usr/lib
ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/ /usr/lib/

I don't know why the old link doesnot work, now try "make" and "make install", kscope would run on my FC5.

Tuesday, June 19, 2007

cscope - the use

I am still learning on use of cscope. Basically I hope to use it with emacs, thus I put "(require xcscope)" in my .emacs file. First problem, is how to generate database index, xcscope uses cscope-indexer, but it seems has problem for me. so I prefer using the following script to generate my sourcecode index.

cd $CSC
find $HLX -regex ".*\.\(c\|h\|cc\|cpp\)" -print > cscope.files
cscope -b -q

Speaking about the script, I have another script (ec) that can share here,

exec emacsclient --no-wait $@

then set variable "export CSCOPE_EDITOR=ec", and my emacs, I have to enable "(server-start)" in my .emacs configuration file. this provides a way that invoke emacs from cscope. Actually I am using the other way, invoke cscope from emacs, that's why I use "xcscope.el".

Now the question is cscope doing good on C++? I don't know, and on my test, with Helix source code and MicroQ source code tree, both works worse :-( For emample of Helix, I search IHXPlayer by symbol, I found 475+4, and by global definition, it is about 31+8. better, not good as I directly go through the SDK document.

I also tried to use Kscope, but after download, I don't know how to build, there is no configure script. is my environment Gnome?

Although I am not happy on source code navigation with cscope, I will continue use it for a while at least a lot of people recommend it.