O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing Behavior By Name

Now it’s time to let the user control the program behavior. One easy way is to look at the name the user used to invoke the program. There is a Linux utility called BusyBox that implements many of the standard Unix command-line programs in one small executable, changing its behavior based on the name. On your system you probably have a /usr/bin/ranlib which is a symbolic link to the libtool program. In this case, libtool works like ranlib when invoked using the ranlib name.

Example 4.1 changes the program’s behavior depending on if it is run as upcase or downcase. To do this, look at the argv array that is passed to main. argv is a contraction of the phrase argument vector. You could call that parameter anything ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required