List of Listings


Chapter 5: Building Software with GNU make

Listing 5.1: The buildit Script (on the CD-ROM at ./source/ch5/buildit )
Listing 5.2: Simple Makefile (on the CD-ROM at ./source/ch5/Makefile.simple )
Listing 5.3: Simple Variable Makefile (on the CD-ROM at ./source/ch5/_Makefile.simpvar )
Listing 5.4: Simple Variable Makefile Output
Listing 5.5: Variable Concatenation Makefile (on the CD-ROM at ./source/ch5/_Makefile.varconcat )
Listing 5.6: Variable Manipulation Makefile (on the CD-ROM at ./source/ch5/_Makefile.varmanip )
Listing 5.7: Output from the Makefile in Listing 5.6
Listing 5.8: More Realistic Makefile (on the CD-ROM at ./source/ch5/_Makefile.realistic)
Listing 5.9: Makefile with Dependency Tracking (on the CD-ROM at ./source/ch5/_Makefile.deptrack )

Chapter 6: Building and Using Libraries

Listing 6.1: Random Number Wrapper API Header (on the CD-ROM at ./source/ch6/_statshrd/randapi.h)
Listing 6.2: Random Number Initialization API (on the CD-ROM at ./source/ch6/_statshrd/initapi.c )
Listing 6.3: Random Number Wrapper Functions (on the CD-ROM at ./source/ch6/_statshrd/randapi.c )
Listing 6.4: Test Application for the Wrapper Function API (on the CD-ROM at ./source/ch6/statshrd/test.c )
Listing 6.5: Updated Test Application for Dynamic Linkage (on the CD-ROM at ./source/ch6/dynamic/test.c )

Chapter 7: Coverage Testing with GNU gcov

Listing 7.1: Sample Source File to Illustrate the gcov Utility (on the CD-ROM at ./source/ch7/bubblesort.c)
Listing 7.2: File bubblesort.c.gcov Resulting from Invocation of gcov Utility
Listing 7.3: File bubblesort.c.gcov Resulting from Invocation of gcov Utility with -b
Listing 7.4: x86 Assembly for the First Branch Point of bubblesort.c.gcov
Listing 7.5: A Sample Program with Incomplete Test Coverage (on the CD-ROM at ./source/ch7/incomptest.c )

Chapter 8: Profiling with GNU gprof

Listing 8.1: Sample Source to Explore the gprof Utility (on the CD-ROM at ./source/ch8/ sort .c)
Listing 8.2: Sample Flat Profile Output from gprof
Listing 8.3: Sample Call Graph Output from gprof
Listing 8.4: Sample Flat Profile Output from gprof for the Optimized Application
Listing 8.5: Sample Source Annotation from gprof for the Sort Application (Incomplete)
Listing 8.6: Sample Function Ordering from gprof
Listing 8.7: Sample Brief Output from gprof
Listing 8.8: Analyzing Multiple Invocations of an Application (on the CD-ROM at ./source/ch8/script )

Chapter 9: Building Packages with automake/autoconf

Listing 9.1: Simple Makefile to Build Example (on the CD-ROM at ./source/ch9/Makefile.simple )
Listing 9.2: Simple autogen .sh Script (on the CD-ROM at ./source/ch9/autogen.sh )
Listing 9.3: Listing of the Root Makefile.am (on the CD-ROM at ./source/ch9/_Makefile.am )
Listing 9.4: Listing of lib/Makefile.am (on the CD-ROM at ./source/ch9/_lib/Makefile.am )
Listing 9.5: Listing of app/Makefile.am (on the CD-ROM at ./source/ch9/_app/Makefile.am )
Listing 9.6: Listing of configure.ac (on the CD-ROM at ./source/ch9/configure.ac )
Listing 9.7: Output from the Example configure Script

Chapter 10: File Handling in GNU/Linux

Listing 10.1: Catching an Error in an fopen Call (on the CD-ROM at ./source/ch10/_test.c )
Listing 10.2: The fputc Character Interface Example (on the CD-ROM at ./source/_ch10/charout.c )
Listing 10.3: The fgetc Character Interface Example (on the CD-ROM at ./source/_ch10/charin.c )
Listing 10.4: Writing Variable Length Strings to a File (on the CD-ROM at ./source/_ch10/strout.c )
Listing 10.5: Reading Variable Length Strings from a File (on the CD-ROM at ./source/_ch10/strin.c )
Listing 10.6: Writing Structured Data in ASCII Format (on the CD-ROM at ./source/_ch10/strucout.c )
Listing 10.7: Reading Structured Data in ASCII Format (on the CD-ROM at ./source/_ch10/strucin.c )
Listing 10.8: Using fwrite to Emit Structured Data (on the CD-ROM at ./source/_ch10/binout.c )
Listing 10.9: Inspecting the Contents of the Generated Binary File
Listing 10.10: Using fread and fseek/rewind to Read Structured Data (on the CD-ROM at ./source/ch10/nonseq.c )

Chapter 11: Programming with Pipes

Listing 11.1: Simple Pipe Example (on the CD-ROM at ./source/ch11/pipe1.c )
Listing 11.2: Illustrating the Pipe Model with Two Processes (on the CD-ROM at ./source/ch11/fpipe.c )
Listing 11.3: Pipelining Commands in C (on the CD-ROM at ./source/ch11/dup.c )

Chapter 12: Introduction to Sockets Programming

Listing 12.1: Daytime Server Written in the C Language (on the CD-ROM at ./source/_ch12/dayserv.c )
Listing 12.2: Daytime Client Written in the C Language (on the CD-ROM at ./source/_ch12/daycli.c )
Listing 12.3: Daytime Protocol Server in the Ruby Language (on the CD-ROM at ./source/ch12/dayserv.rb )
Listing 12.4: Daytime Protocol Client in the Scheme Language (on the CD-ROM at ./source/ch12/daycli.scm )

Chapter 13: GNU/Linux Process Model

Listing 13.1: First Process Example (on the CD-ROM at ./source/ch13/process.c )
Listing 13.2: Working Example of the fork Call (on the CD-ROM at ./source/ch13/smplfork.c )
Listing 13.3: Registering for Catching a Signal (on the CD-ROM at ./source/ch13/_sigcatch.c )
Listing 13.4: Raising a Signal from a Child to a Parent Process (on the CD-ROM at ./source/ch13/raise.c )
Listing 13.5: Signal Demonstration with a Parent and Child Process (on the CD-ROM at ./source/ch13/sigtest.c )
Listing 13.6: Simple Shell Interpreter Using execlp (on the CD-ROM at ./source/ch13/_simpshell.c )
Listing 13.7: Example Use of alarm and Signal Capture (on the CD-ROM at ./source/_ch13/alarm.c )
Listing 13.8: Simple Application Illustrating sigaction for Signal Installation (on the CD-ROM at ./source/ch13/posixsig.c )

Chapter 14: POSIX Threads (Pthreads) Programming

Listing 14.1: Creating a Thread with pthread_create (on the CD-ROM at ./source/_ch14/ptcreate.c )
Listing 14.2: Terminating a Thread with pthread_exit (on the CD-ROM at ./source/_ch14/ptcreate.c )
Listing 14.3: Retrieving the pthread_t Handle with pthread_self (on the CD-ROM at ./source/ch14/ptcreate.c )
Listing 14.4: Providing a Single-use Initialization Function with pthread_once
Listing 14.5: Joining Threads with pthread_join (on the CD-ROM at ./source/ch14/_ptjoin.c )
Listing 14.6: Detaching a Thread from Within with pthread_detach
Listing 14.7: Protecting a Variable in a Critical Section with Mutexes (on the CD-ROM at ./source/ch14/ptmutex.c )
Listing 14.8   Producer/Consumer Example Initialization and main (on the CD-ROM at ./source/ch14/ptcond.c )
Listing 14.9: Producer Thread Example for Condition Variables (on the CD-ROM at ./source/ch14/ptcond.c )
Listing 14.10: Consumer Thread Example for Condition Variables (on the CD-ROM at ./source/ch14/ptcond.c )
Listing 14.11: Application Output for Condition Variable Application

Chapter 15: IPC with Message Queues

Listing 15.1: Common Header File Used by the Sample Applications (on the CD-ROM at ./source/ch15/common.h )
Listing 15.2: Creating a Message Queue with msgget (on the CD-ROM at ./source/ch15/mqcreate.c )
Listing 15.3: Configuring a Message Queue with msgctl (on the CD-ROM at ./source/ch15/mqconf.c )
Listing 15.4: Sending a Message with msgsnd . (on the CD-ROM at ./source/ch15/_mqsend.c )
Listing 15.5: Reading a Message with msgrcv (on the CD-ROM at ./source/ch15/_mqrecv.c )
Listing 15.6: Removing a Message Queue with msgctl (on the CD-ROM at ./source/_ch15/mqdel.c )
Listing 15.7: Setting All Possible Options in msgctl (on the CD-ROM at ./source/_ch15/mqrdset.c )
Listing 15.8: Reading Current Message Queue Settings (on the CD-ROM at ./source/ch15/mqstats.c )

Chapter 16: Synchronization with Semaphores

Listing 16.1: Creating a Semaphore with semget (on the CD-ROM at ./source/ch16/_semcreate.c )
Listing 16.2: Getting a Semaphore with semop
Listing 16.3: Releasing a Semaphore with semop (on the CD-ROM at ./source/ch16/_semrel.c )
Listing 16.4: Execution of the Sample Semaphore Applications
Listing 16.5: Retrieving the Current Semaphore Count (on the CD-ROM at ./source/_ch16/semcrd.c )
Listing 16.6: Setting the Current Semaphore Count
Listing 16.7: Removing a Semaphore
Listing 16.8: Creating and Manipulating Semaphore Arrays (on the CD-ROM at ./source/ch16/semall.c )
Listing 16.9: Output from the semall Application Shown in Listing 16.8
Listing 16.10: Reading Semaphore Information Using IPC_STAT (on the CD-ROM at ./source/ch16/semstat.c )
Listing 16.11: Acquiring an Array of Semaphores Using semop (on the CD-ROM at ./source/ch16/semaacq.c )

Chapter 17: Shared Memory Programming

Listing 17.1: Creating a Shared Memory Segment with shmget (on the CD-ROM at ./source/ch17/shmcreate.c )
Listing 17.2: Retrieving Information about a Shared Memory Segment (on the CD-ROM at ./source/ch17/shmszget.c)
Listing 17.3: Attaching to and Detaching from a Shared Memory Segment (on the CD-ROM at ./source/ch17/shmattch.c )
Listing 17.4: Writing to a Shared Memory Segment (on the CD-ROM at ./source/ch17/_shmwrite.c )
Listing 17.5: Reading from a Shared Memory Segment (on the CD-ROM at ./source/_ch17/shmread.c )
Listing 17.6: Removing a Shared Memory Segment (on the CD-ROM at ./source/_ch17/shmdel.c )
Listing 17.7: The Shared Memory Structure ( shmid_ds )
Listing 17.8: Shared Memory Data Structure Elements Accessible Through shmctl (on the CD-ROM at ./source/ch17/shmstat.c )
isting 17.9: Changing Access Permissions in a Shared Memory Segment (on the CD-ROM at ./source/ch17/shmset.c )
isting 17.10: Shared Memory Example Using Semaphore Coordination (on the CD-ROM at ./source/ch17/shmexpl.c )

Chapter 18: Other Application Development Topics

Listing 18.1: Example Use of getopt (on the CD-ROM at ./source/ch18/opttest.c )
Listing 18.2: Simple Example of getopt_long to Parse Command-line Options (on the CD-ROM at ./source/ch18/optlong.c )
Listing 18.3: Demonstration of Time Conversion Functions (on the CD-ROM at ./source/ch18/time.c )
Listing 18.4: Sample Use of sysinfo Function (on the CD-ROM at ./source/ch18/_sysinfo.c )
Listing 18.5: Mapping Physical Memory with mmap (on the CD-ROM at ./source/ch18/phymap.c )
Listing 18.6: Locking and Unlocking a Memory Page (on the CD-ROM at ./source/_ch18/lock.c )

Chapter 19: GNU/Linux Commands

Listing 19.1: Descriptor Routing Test Script (on CD-ROM at ./source/ch19/_redirtest.sh )
Listing 19.2: Sample File ( passwd ) for Field-based Cutting (on the CD-ROM at ./source/ch19/passwd )
Listing 19.3: The Fruits File (on the CD-ROM at ./source/ch19/fruits.txt )
Listing 19.4   The Tools File (on the CD-ROM at ./source/ch19/tools.txt )
Listing 19.5: Simple Reversed ls Utility Using cut and paste (on the CD-ROM at ./source/ch19/newls.sh )
Listing 19.6: Sample File for Sorting (on the CD-ROM at ./source/ch19/table.txt )

Chapter 20: Bourne-Again Shell (bash)

Listing 20.1: First Bash Script (on the CD-ROM at ./source/ch20/first.sh )
Listing 20.2: Sample Script Illustrating Standard Environmental Variables (on the CD-ROM at ./source/ch20/env.sh )
Listing 20.3: Simple Script Illustrating Arithmetic with Variables (on the CD-ROM at ./source/ch20/ arith .sh )
Listing 20.4: Simple Script Illustrating Basic if/then/else Construct (on the CD-ROM at ./source/ch20/cond.sh )
Listing 20.5: Simple Script Illustrating the if/then/elif/then/fi Construct (on the CD-ROM at ./source/ch20/cond2.sh )
Listing 20.6: Simple Script Illustrating the if/then/fi Construct (on the CD-ROM at ./source/ch20/cond3.sh )
Listing 20.7: Determine File Attributes Using File Test Operators (on the CD-ROM at ./source/ch20/fileatt.sh )
Listing 20.8: Simple Example of the case/esac Construct (on the CD-ROM at ./source/ch20/case.sh )
Listing 20.9: Simple Example of the case/esac Construct (on the CD-ROM at ./source/ch20/case2.sh )
Listing 20.10: Another Example of the case/esac Construct Illustrating Ranges (on the CD-ROM at ./source/ch20/case3.sh )
Listing 20.11: Simple String Example of the case/esac Construct (on the CD-ROM at ./source/ch20/case4.sh )
Listing 20.12: Simple while Loop Example (on the CD-ROM at ./source/ch20/loop.sh )
Listing 20.13: Nested while Loop Example (on the CD-ROM at ./source/ch20/loop2.sh )
Listing 20.14: Simple for Loop Example (on the CD-ROM at ./source/ch20/forloop.sh )
Listing 20.15: Simple for Loop Example Using C-like Construct (on the CD-ROM at ./source/ch20/forloop2.sh )
Listing 20.16: Another for Loop Illustrating String Ranges (on the CD-ROM at ./source/ch20/forloop3.sh )
Listing 20.17: Listing the Users on the System Using Wildcard Replacement (on the CD-ROM at ./source/ch20/forloop4.sh )
Listing 20.18: Creating a Function That Utilizes Parameters (on the CD-ROM at ./source/ch20/func.sh )
Listing 20.19: Adding Error Checking to Our Previous Function (on the CD-ROM at ./source/ch20/func2.sh )
Listing 20.20: Adding Function return to Our Previous sum Function (on the CD-ROM at ./source/ch20/func3.sh )
Listing 20.21: Directory Archive Script (on the CD-ROM at ./source/ch20/archive.sh )
Listing 20.22: Files Updated/Created Today Script (on the CD-ROM at ./source/_ch20/fut.sh )

Chapter 21: Editing with sed

Listing 21.1: Sample File for sed Illustration (on the CD-ROM at ./source/ch21/_file.txt )

Chapter 22: Text Processing with awk

Listing 22.1: Missile Data for awk Scripts. (This information can also be viewed at the Strategic Air Command Web site at http://www.strategic-air-command.com and on the CD-ROM at ./source/ch22/missiles.txt )
Listing 22.2: Expanding Our Summing Application (on the CD-ROM at ./source/ch21/_tabulate.awk )
Listing 22.3: Finding and Storing the Extremes (on the CD-ROM at ./source/ch21/_order.awk )
Listing 22.4: Replacement of the END Section of Listing 22.3 (on the CD-ROM at ./source/ch21/order2.awk )
Listing 22.5: Generating a Data Table (on the CD-ROM at ./source/ch21/table.awk )
Listing 22.6: Generating a Data Table Using a while Loop (on the CD-ROM at ./source/ch21/table2.awk )

Chapter 23: Parser Generation with flex and bison

Listing 23.1: Simple flex Input File Example (on the CD-ROM at ./source/ch23/_simple/example.fl )
Listing 23.2: Test of Simple Lexer Specified in Listing 23.1
Listing 23.3: bison Grammar File for Our Simple set Example (on the CD-ROM at ./source/ch23/setexample/grammar.y )
Listing 23.4: Upgraded flex Input File (on the CD-ROM at ./source/ch23/setexample/tokens.l )
Listing 23.5: Sample Use of the set Parser
Listing 23.6: Sample E-Mail Firewall Configuration File (on the CD-ROM at ./source/ch23/config/config.file )
Listing 23.7: Configuration Parser flex Input File (on the CD-ROM at ./source/ch23/_config/config.fl )
Listing 23.8: Configuration Parser bison Input File (on the CD-ROM at ./source/ch23/_config/config.y )
Listing 23.9: Sample Configuration File

Chapter 24: Software Unit Testing Frameworks

Listing 24.1: Stack Module Source (on the CD-ROM at ./source/ch24/byo/stack.c )
Listing 24.2: Stack Module Header File (on the CD-ROM at ./source/ch24/byo/stack.h )
Listing 24.3: Result Checking Function for a Simple Regression (on the CD-ROM at ./source/ch24/byo/regress.c )
Listing 24.4: Simple Regression main (on the CD-ROM at ./source/ch24/byo/regress.c )
Listing 24.5: Stack Module Regression Focusing on Creation and Destruction (on the CD-ROM at ./source/ch24/byo/regress.c )
Listing 24.6: Unit Test Example Written for Cut (on the CD-ROM at ./source/ch24/_cut/test_1.c )
Listing 24.7: Unit Test Environment Source Created By cutgen
Listing 24.8: Unit Test Coded for the Embunit Framework (on the CD-ROM at ./source/ch24/emb/stackTest.c )
Listing 24.9: Embunit Main Program (on the CD-ROM at ./source/ch24/emb/main.c )
Listing 24.10: Testing the bc Calculator with expect (on the CD-ROM at ./source/ch24/expect/test_bc )

Chapter 25: Debugging with GDB

Listing 25.1: Example Source for the GDB Debugging Session (on the CD-ROM at ./source/ch25/testapp.c )

Chapter 26: Code Hardening

Listing 26.1   Illustrating a Self-identifying Structure (on the CD-ROM at ./source/ch26/selfident.c )
Listing 26.2   Simple Example of syslog Use (on the CD-ROM at ./source/ch26/_simpsyslog.c )
Listing 26.3   Example of a Self-protective Function (on the CD-ROM at ./source/ch26/_selfprot.c )
Listing 26.4   Poorly Hardened Application (on the CD-ROM at ./source/ch26/badprog.c )



GNU/Linux Application Programming
GNU/Linux Application Programming (Programming Series)
ISBN: 1584505680
EAN: 2147483647
Year: 2006
Pages: 203
Authors: M. Tim Jones

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net