+ All Categories
Home > Education > Beginning linux-programming

Beginning linux-programming

Date post: 19-Nov-2014
Category:
Upload: kunal-dawn
View: 5,956 times
Download: 10 times
Share this document with a friend
Description:
 
Popular Tags:
804
Transcript
  • 1. Table of ContentsBeginning Linux Programming, Second Edition.............................................................................................1Foreword..............................................................................................................................................................5Introduction.........................................................................................................................................................6Welcome.................................................................................................................................................6Whos this Book For?..............................................................................................................................6Whats Covered in the Book...................................................................................................................6What You Need to Use this Book...........................................................................................................8Source Code............................................................................................................................................9Conventions............................................................................................................................................9Tell Us What You Think.......................................................................................................................10Why Should I Return the Reply Card?.................................................................................................10Chapter 1: Getting Started.............................................................................................................................11Overview...............................................................................................................................................11What is UNIX?.....................................................................................................................................11What is Linux?......................................................................................................................................11Distributions..........................................................................................................................................11The GNU Project and the Free Software Foundation...........................................................................12Programming Linux..............................................................................................................................13UNIX Programs....................................................................................................................................13The C Compiler..............................................................................................................................14Try It Out Our First UNIX C Program........................................................................................14How It Works..................................................................................................................................15Getting Help..........................................................................................................................................15Try It Out Manual Pages and info................................................................................................16Development System Roadmap............................................................................................................17Programs.........................................................................................................................................17Header Files....................................................................................................................................18Library Files...................................................................................................................................19Static Libraries...............................................................................................................................19Try It Out Static Libraries............................................................................................................20Shared Libraries.............................................................................................................................22UNIX Philosophy.................................................................................................................................23Simplicity.......................................................................................................................................23Focus..............................................................................................................................................23Reusable Components....................................................................................................................23Filters..............................................................................................................................................23Open File Formats..........................................................................................................................23Flexibility.......................................................................................................................................23Summary...............................................................................................................................................24Chapter 2: Shell Programming.......................................................................................................................25Overview...............................................................................................................................................25What is a Shell?....................................................................................................................................26Pipes and Redirection...........................................................................................................................27Redirecting Output.........................................................................................................................27Redirecting Input............................................................................................................................28Pipes...............................................................................................................................................28i

2. Table of ContentsChapter 2: Shell ProgrammingThe Shell as a Programming Language................................................................................................29Interactive Programs.......................................................................................................................29Creating a Script.............................................................................................................................30Making a Script Executable...........................................................................................................31Shell Syntax..........................................................................................................................................32Variables.........................................................................................................................................33Conditions......................................................................................................................................36Control Structures...........................................................................................................................38Functions........................................................................................................................................49Try It Out A Simple Function......................................................................................................50How It Works..................................................................................................................................50Try It Out Returning a Value.......................................................................................................51How It Works..................................................................................................................................52Commands......................................................................................................................................52Command Execution......................................................................................................................62Here Documents.............................................................................................................................66Try It Out Using Here Documents...............................................................................................66Try It Out Another Use for a Here Document.............................................................................67How It Works..................................................................................................................................67Debugging Scripts..........................................................................................................................67Putting it All Together..........................................................................................................................68Requirements..................................................................................................................................68Design.............................................................................................................................................69Try It Out A CD Application.......................................................................................................70Notes................................................................................................................................................76Summary...............................................................................................................................................77Chapter 3: Working with Files.......................................................................................................................78Overview...............................................................................................................................................78UNIX File Structure..............................................................................................................................78Directories......................................................................................................................................79Files and Devices............................................................................................................................79System Calls and Device Drivers.........................................................................................................81Library Functions..................................................................................................................................82Lowlevel File Access..........................................................................................................................82write.................................................................................................................................................83read..................................................................................................................................................83open.................................................................................................................................................84Initial Permissions...........................................................................................................................85umask...............................................................................................................................................86close.................................................................................................................................................87ioctl..................................................................................................................................................87Try It Out A File Copy Program..................................................................................................87Other System Calls for Managing Files.........................................................................................89The Standard I/O Library......................................................................................................................91fopen................................................................................................................................................92fread.................................................................................................................................................92fwrite...............................................................................................................................................93fclose...............................................................................................................................................93ii 3. Table of ContentsChapter 3: Working with Filesfflush................................................................................................................................................93fseek.................................................................................................................................................93fgetc, getc, getchar...........................................................................................................................94fputc, putc, putchar..........................................................................................................................94fgets, gets.........................................................................................................................................94Formatted Input and Output...........................................................................................................95Other Stream Functions..................................................................................................................98Try It Out Another File Copy Program.......................................................................................99Stream Errors..................................................................................................................................99Streams and File Descriptors........................................................................................................100File and Directory Maintenance..........................................................................................................101chmod............................................................................................................................................101chown............................................................................................................................................101unlink, link, symlink......................................................................................................................101mkdir, rmdir...................................................................................................................................102chdir, getcwd.................................................................................................................................102Scanning Directories...........................................................................................................................103opendir...........................................................................................................................................103readdir............................................................................................................................................103telldir.............................................................................................................................................104seekdir...........................................................................................................................................104closedir..........................................................................................................................................104Try It Out A Directory Scanning Program................................................................................105How It Works................................................................................................................................106Errors...................................................................................................................................................107Advanced Topics................................................................................................................................107fcntl................................................................................................................................................108mmap.............................................................................................................................................109Try It Out Using mmap.............................................................................................................110Summary.............................................................................................................................................111Chapter 4: The UNIX Environment............................................................................................................112Overview.............................................................................................................................................112Program Arguments............................................................................................................................112Try It Out Program Arguments.................................................................................................113How It Works................................................................................................................................114getopt............................................................................................................................................114Try It Out getopt.......................................................................................................................115How It Works................................................................................................................................116Environment Variables.......................................................................................................................116Try It Out getenv and putenv0...................................................................................................117Use of Environment Variables.....................................................................................................118The environ Variable....................................................................................................................119Try It Out environ......................................................................................................................119How It Works................................................................................................................................119Time and Date.....................................................................................................................................119Try It Out time...........................................................................................................................120How It Works................................................................................................................................121Try It Out gmtime.....................................................................................................................121iii 4. Table of ContentsChapter 4: The UNIX EnvironmentHow It Works................................................................................................................................122Try It Out ctime.........................................................................................................................123How It Works................................................................................................................................123Try It Out strftime and strptime................................................................................................125How It Works................................................................................................................................126Temporary Files..................................................................................................................................126Try It Out tmpnam and tmpfile.................................................................................................127How It Works................................................................................................................................127User Information.................................................................................................................................128Try It Out User Information.......................................................................................................129How It Works................................................................................................................................130Other User Information Functions...............................................................................................130Host Information.................................................................................................................................131Try It Out Host Information.......................................................................................................131How It Works................................................................................................................................132Licensing......................................................................................................................................132Logging...............................................................................................................................................132Try It Out syslog........................................................................................................................134How It Works................................................................................................................................134Configuring Logs.........................................................................................................................134Try It Out logmask.....................................................................................................................135How It Works................................................................................................................................136Resources and Limits..........................................................................................................................136Try It Out Resource Limits.......................................................................................................138How It Works................................................................................................................................140Summary.............................................................................................................................................140Chapter 5: Terminals....................................................................................................................................141Overview.............................................................................................................................................141Reading from and Writing to the Terminal.........................................................................................141Try It Out Menu Routines in C..................................................................................................141How It Works................................................................................................................................142Why It Doesnt Quite Work...........................................................................................................143Handling Redirected Output.........................................................................................................144Try It Out Checking for Output Redirection..............................................................................144How It Works................................................................................................................................145Talking to the Terminal................................................................................................................145Try It Out Using /dev/tty............................................................................................................146The Terminal Driver and the General Terminal Interface..................................................................147Overview......................................................................................................................................147Hardware Model...........................................................................................................................148The termios Structure..........................................................................................................................149Input Modes..................................................................................................................................150Output Modes...............................................................................................................................151Control Modes..............................................................................................................................152Local Modes.................................................................................................................................152Special Control Characters...........................................................................................................153Terminal Speed.............................................................................................................................156Additional Functions....................................................................................................................156iv 5. Table of ContentsChapter 5: TerminalsTry It Out A Password Program with termios...........................................................................157How It Works................................................................................................................................158Try It Out Reading Each Character............................................................................................158How It Works................................................................................................................................159Terminal Output..................................................................................................................................159Terminal Type..............................................................................................................................159Identify Your Terminal Type.......................................................................................................160Using terminfo Capabilities..........................................................................................................162Detecting Keystrokes..........................................................................................................................167Try It Out Your Very Own kbhit...............................................................................................167How It Works................................................................................................................................169Pseudo Terminals.........................................................................................................................169Summary.............................................................................................................................................169Chapter 6: Curses..........................................................................................................................................170Overview.............................................................................................................................................170Compiling with curses........................................................................................................................170Concepts..............................................................................................................................................171Try It Out A Simple curses Program.........................................................................................172Initialization and Termination.............................................................................................................173Output to the Screen............................................................................................................................173Reading from the Screen.....................................................................................................................174Clearing the Screen.............................................................................................................................175Moving the Cursor..............................................................................................................................175Character Attributes............................................................................................................................175Try It Out Moving, Inserting and Attributes..............................................................................176The Keyboard......................................................................................................................................177Keyboard Modes..........................................................................................................................177Keyboard Input.............................................................................................................................178Try It Out Keyboard Modes and Input........................................................................................178How It Works................................................................................................................................179Windows.............................................................................................................................................180The WINDOW Structure..............................................................................................................180Generalized Functions..................................................................................................................180Moving and Updating a Window.................................................................................................181Try It Out Multiple Windows....................................................................................................182Optimizing Screen Refreshes.......................................................................................................184Subwindows........................................................................................................................................185Try It Out Subwindows..............................................................................................................185How It Works................................................................................................................................187The Keypad.........................................................................................................................................187Try It Out Using the Keypad.....................................................................................................188Color...................................................................................................................................................189Try It Out Colors.......................................................................................................................190Redefining Colors.........................................................................................................................191Pads.....................................................................................................................................................191Try It Out Using a Pad...............................................................................................................192The CD Collection Application..........................................................................................................193Try It Out A New CD Collection Application...........................................................................194v 6. Table of ContentsChapter 6: CursesTry It Out Looking at main........................................................................................................196Try It Out The Menu..................................................................................................................196Try It Out Database File Manipulation.....................................................................................198Try It Out Querying the CD Database.......................................................................................202Summary.............................................................................................................................................206Chapter 7: Data Management......................................................................................................................207Overview.............................................................................................................................................207Managing Memory..............................................................................................................................207Simple Memory Allocation..........................................................................................................207Try It Out Simple Memory Allocation......................................................................................208How It Works................................................................................................................................208Allocating Lots of Memory..........................................................................................................208Try It Out Asking for all Physical Memory..............................................................................209How It Works................................................................................................................................209Try It Out Available Memory....................................................................................................210How It Works................................................................................................................................210Abusing Memory..........................................................................................................................211Try It Out Abuse Your Memory................................................................................................211How It Works................................................................................................................................212The Null Pointer...........................................................................................................................212Try It Out Accessing a Null Pointer..........................................................................................212How It Works................................................................................................................................213How It Works................................................................................................................................213Freeing Memory...........................................................................................................................213Try It Out Freeing Memory.......................................................................................................214How It Works................................................................................................................................214Other Memory Allocation Functions...........................................................................................214File Locking........................................................................................................................................215Creating Lock Files......................................................................................................................215Try It Out Creating a Lock File.................................................................................................216How It Works................................................................................................................................216Try It Out Cooperative Lock Files............................................................................................217How It Works................................................................................................................................218Locking Regions...........................................................................................................................218Use of read and write with Locking.............................................................................................221Try It Out Locking a File with fcntl...........................................................................................221How It Works................................................................................................................................222Try It Out Testing Locks on a File.............................................................................................223How It Works................................................................................................................................225Competing Locks.........................................................................................................................226Try It Out Competing Locks.....................................................................................................226How It Works................................................................................................................................228Other Lock Commands................................................................................................................228Deadlocks.....................................................................................................................................229Databases............................................................................................................................................229The dbm Database........................................................................................................................229The dbm Routines........................................................................................................................230dbm Access Functions..................................................................................................................232vi 7. Table of ContentsChapter 7: Data ManagementAdditional dbm Functions............................................................................................................235The CD Application............................................................................................................................237The CD Application Using dbm...................................................................................................238Try It Out cd_data.h...................................................................................................................238Try It Out app_ui.c.....................................................................................................................239Try It Out cd_access.c...............................................................................................................247Summary.............................................................................................................................................253Chapter 8: Development Tools.....................................................................................................................254Overview.............................................................................................................................................254Problems of Multiple Source Files.....................................................................................................254The make Command and Makefiles...................................................................................................255The Syntax of Makefiles..............................................................................................................255Options and Parameters to make..................................................................................................255Comments in a makefile...............................................................................................................258Macros in a makefile....................................................................................................................258Try It Out A Makefile with Macros...........................................................................................259How It Works................................................................................................................................259Multiple Targets...........................................................................................................................260Try It Out Multiple Targets........................................................................................................260How It Works................................................................................................................................262Builtin Rules..............................................................................................................................262Suffix Rules..................................................................................................................................263Try It Out Suffix Rules..............................................................................................................263How It Works................................................................................................................................264Managing Libraries with make.....................................................................................................264Try It Out Managing a Library..................................................................................................264How It Works................................................................................................................................265Advanced Topic: Makefiles and Subdirectories..........................................................................266GNU make and gcc......................................................................................................................266Try It Out gcc MM...................................................................................................................267How It Works................................................................................................................................267Source Code Control...........................................................................................................................267RCS..............................................................................................................................................267SCCS............................................................................................................................................273CVS..............................................................................................................................................274Writing a Manual Page.......................................................................................................................278Distributing Software..........................................................................................................................281The patch Program.......................................................................................................................281Other Distribution Utilities...........................................................................................................283Summary.............................................................................................................................................285Chapter 9: Debugging....................................................................................................................................286Types of Error.....................................................................................................................................286Specification Errors......................................................................................................................286Design Errors................................................................................................................................286Coding Errors...............................................................................................................................286General Debugging Techniques..........................................................................................................287A Program with Bugs...................................................................................................................287vii 8. Table of ContentsChapter 9: DebuggingCode Inspection............................................................................................................................289Instrumentation.............................................................................................................................290Try It Out Debug Information....................................................................................................291How It Works................................................................................................................................291Controlled Execution....................................................................................................................292Debugging with gdb............................................................................................................................293Starting gdb..................................................................................................................................293Running a Program.......................................................................................................................294Stack Trace...................................................................................................................................294Examining Variables....................................................................................................................295Listing the Program......................................................................................................................296Setting Breakpoints......................................................................................................................296Patching with the Debugger.........................................................................................................299Learning more about gdb.............................................................................................................300More Debugging Tools.......................................................................................................................300Lint: Removing the Fluff from Your Programs...........................................................................301Function Call Tools......................................................................................................................302Execution Profiling.......................................................................................................................304Assertions............................................................................................................................................304Problems with assert.....................................................................................................................305Try It Out assert........................................................................................................................305How It Works................................................................................................................................306Memory Debugging............................................................................................................................306ElectricFence................................................................................................................................307Try It Out ElectricFence............................................................................................................307How It Works................................................................................................................................308Checker.........................................................................................................................................308Try It Out Checker.....................................................................................................................308How It Works................................................................................................................................309Resources............................................................................................................................................310Summary.............................................................................................................................................310Chapter 10: Processes and Signals...............................................................................................................311Overview.............................................................................................................................................311What is a Process?..............................................................................................................................311Process Structure.................................................................................................................................311The Process Table........................................................................................................................313Viewing Processes........................................................................................................................313System Processes..........................................................................................................................314Process Scheduling.......................................................................................................................315Starting New Processes.......................................................................................................................316Try It Out system.......................................................................................................................316How It Works................................................................................................................................317Replacing a Process Image............................................................................................................317Try It Out execlp.......................................................................................................................318How It Works................................................................................................................................319Duplicating a Process Image.........................................................................................................319Try It Out fork...........................................................................................................................320How It Works................................................................................................................................321viii 9. Table of ContentsChapter 10: Processes and SignalsWaiting for a Process...................................................................................................................321Try It Out wait............................................................................................................................322How It Works................................................................................................................................323Zombie Processes.........................................................................................................................323Try It Out Zombies....................................................................................................................324How It Works................................................................................................................................324Input and Output Redirection.......................................................................................................325Try It Out Redirection...............................................................................................................325How It Works................................................................................................................................326Threads.........................................................................................................................................326Signals.................................................................................................................................................326Try It Out Signal Handling.......................................................................................................328How It Works................................................................................................................................329Sending Signals............................................................................................................................330Try It Out An Alarm Clock........................................................................................................330How It Works................................................................................................................................331Signal Sets....................................................................................................................................334Summary.............................................................................................................................................337Chapter 11: POSIX Threads.........................................................................................................................338What is a Thread?...............................................................................................................................338Advantages and Drawbacks of Threads.......................................................................................338Checking for Thread Support..............................................................................................................339Try it out POSIX compliance test..............................................................................................339How it works.................................................................................................................................340A First Threads Program.....................................................................................................................340Try it out a simple threaded program.........................................................................................342How it works.................................................................................................................................343Simultaneous Execution.....................................................................................................................344Try it out simultaneous execution of two threads......................................................................344How it works.................................................................................................................................345Synchronization..................................................................................................................................345Synchronization with Semaphores...............................................................................................345Try it out a thread semaphore....................................................................................................347How it works.................................................................................................................................349Synchronization with Mutexes.....................................................................................................350Try it out a thread mutex............................................................................................................350How it works.................................................................................................................................352Thread Attributes................................................................................................................................353detachedstate.................................................................................................................................354schedpolicy....................................................................................................................................354schedparam....................................................................................................................................355inheritsched...................................................................................................................................355scope..............................................................................................................................................355stacksize.........................................................................................................................................355Try it out setting the detached state attribute.............................................................................355How it works.................................................................................................................................356Thread Attributes Scheduling....................................................................................................357Try is out scheduling..................................................................................................................357ix 10. Table of ContentsChapter 11: POSIX ThreadsHow it works.................................................................................................................................357Canceling a Thread.............................................................................................................................357Try it out canceling a thread......................................................................................................358How it works.................................................................................................................................360Threads in Abundance........................................................................................................................360Try it out many threads..............................................................................................................360How it works.................................................................................................................................362Summary.............................................................................................................................................363Chapter 12: Interprocess Communication: Pipes....................................................................................364Overview.............................................................................................................................................364What is a Pipe?....................................................................................................................................364Process Pipes.......................................................................................................................................365popen.............................................................................................................................................365pclose.............................................................................................................................................365Try It Out Reading Output From an External Program............................................................365How It Works................................................................................................................................366Sending Output to popen..............................................................................................................366Try It Out Sending Output to an External Program...................................................................366How It Works................................................................................................................................367The Pipe Call......................................................................................................................................369Try It Out The pipe Function.....................................................................................................370How It Works................................................................................................................................371Try It Out Pipes across a fork...................................................................................................371How It Works................................................................................................................................372Parent and Child Processes.................................................................................................................372Try It Out Pipes and exec...........................................................................................................372How It Works................................................................................................................................373Reading Closed Pipes...................................................................................................................374Pipes Used as Standard Input and Output....................................................................................374Named Pipes: FIFOs...........................................................................................................................377Try It Out Creating a Named Pipe.............................................................................................378How It Works................................................................................................................................378Accessing a FIFO.........................................................................................................................378Try It Out Accessing a FIFO File.............................................................................................379How It Works................................................................................................................................379Advanced Topic: Client/Server using FIFOs......................................................................................385Try It Out An Example Client/Server Application...................................................................385How It Works................................................................................................................................388The CD Application............................................................................................................................388Aims.............................................................................................................................................389Implementation.............................................................................................................................390Try It Out The Header File, cliserv.h.........................................................................................392Client Interface Functions............................................................................................................393Try It Out The Clients Interpreter.............................................................................................393The Server Interface.....................................................................................................................399Try It Out server.c......................................................................................................................399The Pipe........................................................................................................................................402Try It Out Pipes Implementation Header...................................................................................402x 11. Table of ContentsChapter 12: Interprocess Communication: PipesApplication Summary...................................................................................................................407Summary.............................................................................................................................................407Chapter 13: Semaphores, Message Queues and Shared Memory.............................................................409Semaphores.........................................................................................................................................409Semaphore Definition...................................................................................................................410A Theoretical Example.................................................................................................................410UNIX Semaphore Facilities.........................................................................................................411Using Semaphores........................................................................................................................413Try It Out Semaphores...............................................................................................................414How It Works................................................................................................................................416Semaphore Summary...................................................................................................................417Shared Memory...................................................................................................................................417Overview......................................................................................................................................417Shared Memory Functions...........................................................................................................418Shared Memory Summary............................................................................................................423Message Queues..................................................................................................................................423Overview......................................................................................................................................424Message Queue Functions............................................................................................................424Message Queue Summary............................................................................................................429The Application..................................................................................................................................429Try It Out Revising the Server Functions..................................................................................429Try It Out Revising the Client Functions...................................................................................431IPC Status Commands........................................................................................................................433Semaphores..................................................................................................................................433Shared Memory............................................................................................................................433Message Queues...........................................................................................................................433Summary.............................................................................................................................................434Chapter 14: Sockets.......................................................................................................................................435Overview.............................................................................................................................................435What is a Socket?................................................................................................................................435Socket Connections.............................................................................................................................435Try It Out A Simple Local Client..............................................................................................436Try It Out A Simple Local Server.............................................................................................437Socket Attributes..........................................................................................................................439Creating a Socket..........................................................................................................................441Socket Addresses..........................................................................................................................442Naming a Socket..........................................................................................................................442Creating a Socket Queue..............................................................................................................443Accepting Connections.................................................................................................................443Requesting Connections...............................................................................................................444Closing a Socket...........................................................................................................................445Socket Communications...............................................................................................................445Try It Out Network Client..........................................................................................................446How It Works................................................................................................................................446Try It Out Network Server........................................................................................................446How It Works................................................................................................................................447Host and Network Byte Ordering.................................................................................................447xi 12. Table of ContentsChapter 14: SocketsNetwork Information..........................................................................................................................449Try It Out Network Information...............................................................................................450How It Works................................................................................................................................451Try It Out Connecting to a Standard Service............................................................................452How It Works................................................................................................................................453The Internet Daemon....................................................................................................................453Socket Options.............................................................................................................................454Multiple Clients..................................................................................................................................454Try It Out A Server for Multiple Clients...................................................................................455How It Works................................................................................................................................457select...................................................................................................................................................457Try It Out select.........................................................................................................................458How It Works................................................................................................................................460Multiple Clients............................................................................................................................460Try It Out An Improved Multiple Client/Server........................................................................460Summary.............................................................................................................................................463Chapter 15: Tcl: Tool Command Language...............................................................................................464Overview.............................................................................................................................................464A Tcl Overview...................................................................................................................................464Our First Tcl Program..................................................................................................................464Tcl Commands.............................................................................................................................465Variables and Values....................................................................................................................466Quoting and Substitution..............................................................................................................467Calculation....................................................................................................................................470Control Structures.........................................................................................................................471Error Handling..............................................................................................................................473String Operations..........................................................................................................................474Arrays...........................................................................................................................................479Lists..............................................................................................................................................481Procedures....................................................................................................................................486Try It Out Procedures................................................................................................................486How It Works................................................................................................................................487Input and Output...........................................................................................................................487A Tcl Program.....................................................................................................................................491Try It Out A Concordance Program...........................................................................................491How It Works................................................................................................................................493Network Support...........................................................................................................................493Try It Out socket.......................................................................................................................494How It Works................................................................................................................................494Creating a New Tcl.............................................................................................................................494Tcl Extensions.....................................................................................................................................494expect............................................................................................................................................494[incr Tcl].......................................................................................................................................495TclX..............................................................................................................................................495Graphics........................................................................................................................................495Summary.............................................................................................................................................495xii 13. Table of ContentsChapter 16: Programming for X..................................................................................................................496Overview.............................................................................................................................................496What is X?...........................................................................................................................................496X Server.........................................................................................................................................497X Protocol......................................................................................................................................497Xlib................................................................................................................................................497X Clients........................................................................................................................................497X Toolkits.....................................................................................................................................497X Window Manager............................................................................................................................498The X Programming Model................................................................................................................499Start Up.........................................................................................................................................499Main Loop....................................................................................................................................500Clean Up.......................................................................................................................................500Fast Track X Programming.................................................................................................................501The Tk Toolkit....................................................................................................................................501Windows Programming................................................................................................................502Try It Out Saying Hello.............................................................................................................503How It Works................................................................................................................................503Configuration Files.......................................................................................................................504More Commands..........................................................................................................................504Tk Widgets...................................................................................................................................505Try It Out Learning More..........................................................................................................505How It Works................................................................................................................................506Tks Builtin Dialogs...................................................................................................................529Color Chooser................................................................................................................................529Get Open/Save Files......................................................................................................................530Color Schemes..............................................................................................................................531Fonts.............................................................................................................................................532Bindings........................................................................................................................................532BindTags......................................................................................................................................533Geometry Management................................................................................................................535Focus and Navigation...................................................................................................................537Option Database...........................................................................................................................538Interapplication Communication................................................................................................539Selection.......................................................................................................................................539Clipboard......................................................................................................................................540Window Manager.........................................................................................................................541Dynamic/Static Loading...............................................................................................................542Safe Tk.........................................................................................................................................543A MegaWidget.................................................................................................................................544Package File Generation................................................................................................................553An Application Using the Tree MegaWidget...................................................................................554Tk Process Log Viewer.......................................................................................................................556Internationalization.......................................................................................................................566Where Now?.................................................................................................................................567Tix.................................................................................................................................................567[incr Tk].........................................................................................................................................567BLT...............................................................................................................................................567Summary.............................................................................................................................................568xiii 14. Table of ContentsChapter 17: Programming GNOME using GTK+.....................................................................................569Overview.............................................................................................................................................569An Introduction to GNOME...............................................................................................................569The GNOME Architecture...........................................................................................................570The GNOME Desktop..................................................................................................................571Programming in GNOME using GTK+.......................................................................................572An Application in GNOME.........................................................................................................586Summary.............................................................................................................................................594Chapter 18: The Perl Programming Language..........................................................................................595Overview.............................................................................................................................................595An Introduction to Perl.................................................................................................................595A Full Example............................................................................................................................612Perl on the Command Line...........................................................................................................617Modules.........


Recommended