UNIX Systems Programming for SVR4 Contents
  Preface Contents
About This Book
Scope of This Book
Audience
Assumptions
Font Conventions
Example Programs
FTP
Ftpmail
BITFTP
UUCP
Comments and Questions
Acknowledgments
Chapter 1 - - Introduction to SVR4
Overview
Standards Compliance
Notes on Compilers
The HP-UX 10.x Compiler
The IRIX 5.x Compiler
The Solaris 2.x Compiler
The GNU C Compiler
The BSD Source Compatibility Package
Chapter 2 - - Utility Routines
Overview
Manipulating Character Strings
Computing the Length of a String
Comparing Character Strings
Copying Character Strings
Searching Character Strings
Non-Standard Character String Functions
Porting Notes
Manipulating Byte Strings
Comparing Byte Strings
Copying Byte Strings
Searching Byte Strings
Initializing Byte Strings
Porting Notes
Manipulating Character Classes
Testing Character Class Membership
Changing Character Class Membership
Porting Notes
Dynamic Memory Allocation
Porting Notes
Manipulating Temporary Files
Porting Notes
Parsing Command-Line Arguments
Porting Notes
Miscellaneous Functions
String to Number Conversion
Printing Error Messages
Porting Notes
Pausing a Program
Exiting a Program
Chapter Summary
Chapter 3 - - Low-Level I/O Routines
Overview
File Descriptors
Opening and Closing Files
Porting Notes
Input and Output
Repositioning the Read/Write Offset
Porting Notes
Duplicating File Descriptors
Chapter Summary
Chapter 4 - - The Standard I/O Library
Overview
Data Types and Constants
Opening and Closing Files
Porting Notes
Character-Based Input and Output
Line-Based Input and Output
Buffer-Based Input and Output
Formatted Input and Output
The printf Functions
The scanf Functions
Porting Notes
Repositioning the Read/Write Offset
Reassigning a File Pointer
Buffering
Porting Notes
Stream Status
File Pointers and File Descriptors
Chapter Summary
Chapter 5 - - Files and Directories
Overview
Filesystem Concepts
The UNIX Filesystem
Basic File Types
Removable Filesystems
Device Numbers
I-numbers, the I-list, and I-nodes
Other File Types
Obtaining File Attributes
Getting Information from an I-node
Getting Information from a Symbolic Link
Determining the Accessibility of a File
Changing File Attributes
Changing a File’s Permission Bits
Changing a File’s Ownership
Changing a File’s Size
Changing a File’s Access and Modification Times
Creating and Deleting Files and Directories
Deleting Files
Creating and Deleting Directories
Creating Links
Renaming Files and Directories
Working with Directories
Determining the Current Working Directory
Changing the Current Working Directory
Reading Directories
Chapter Summary
Chapter 6 - - Special-Purpose File Operations
Overview
File Descriptor Attributes
Managing Multiple File Descriptors
The select Function
The poll Function
File and Record Locking
Locking Files with fcntl
Locking Files with lockf
Porting Notes
Memory-Mapped Files
Mapping a File into Memory
Removing a Mapping
Changing the Protection Mode of Mapped Segments
Providing Advice to the System
Synchronizing Memory with Physical Storage
The /dev/fd Filesystem
Miscellaneous Functions
Controlling File Creation Modes
The Root Directory
Synchronizing a File with the Disk
Chapter Summary
Chapter 7 - - Time of Day Operations
Overview
The Complexities of Time
Obtaining the Current Time
Porting Notes
Obtaining the Local Time Zone
Porting Notes
Converting Between UNIX Time and Human Time
Porting Notes
Formatting Date Strings
Porting Notes
Chapter Summary
Chapter 8 - - Users and Groups
Overview
Login Names
The User ID Number
Porting Notes
The Group ID Number
Porting Notes
Group Membership
The Password File
The Shadow Password File
The Group File
The utmp and wtmp Files
Porting Notes
The Lastlog File
The Shells File
Writing Set-User-Id and Set-Group-Id Programs
Chapter Summary
Chapter 9 - - System Configuration and Resource Limits
Overview
General System Information
Porting Notes
System Resource Limits
Porting Notes
Process Resource Limits
Porting Notes
Resource Utilization Information
Porting Notes
Chapter Summary
Chapter 10 - - Signals
Overview
Signal Concepts
Basic Signal Handling
Sending Signals
Waiting for Signals
Printing Signal Information
Handling Signals
Unreliable Signals
Reliable Signals
The sigset Function
Other Functions
Signals and System Calls
Using Signals for Timeouts
The setjmp and longjmp Functions
Interval Timers
Advanced Signal Handling
Signal Sets
The sigaction Function
Other Functions
Porting Berkeley Signals to SVR4
The sigvec Function
Handler Calling Conventions
Signal Masks
Waiting for Signals
The setjmp and longjmp Functions
Chapter Summary
Chapter 11 - - Processes
Overview
Process Concepts
Process Identifiers
Termination Status
Process Groups
Sessions
The Controlling Terminal
Priorities
Program Termination
Simple Program Execution
Advanced Program Execution
Creating a New Process
Executing a Program
Collecting the Process Termination Status
The vfork Function
Redirecting Input and Output
Job Control
Timing Process Execution
Porting Notes
Chapter Summary
Chapter 12 - - Terminals
Overview
Overview of Terminal I/O
Special Characters
Terminal Characteristics
Terminal-Related Functions
POSIX Terminal Control
Examining and Changing Terminal Attributes
Baud Rates
Job Control Functions
Other Functions
Canonical Mode
Non-Canonical Mode
Pre-POSIX Terminal Control
System V Terminal Control
BSD Terminal Control
Terminal Window Size
Chapter Summary
Chapter 13 - - Interprocess Communication
Overview
Pipes
Simple Pipe Creation
Advanced Pipe Creation
FIFOs
UNIX-Domain Sockets
Creating a Socket
Server-Side Functions
Connecting to a Server
Transferring Data
Destroying the Communications Channel
Putting it All Together
System V IPC Functions
Message Queues
Shared Memory
Semaphores
Chapter Summary
Chapter 14 - - Networking with Sockets
Overview
Networking Concepts
Host Names and Addresses
Services and Port Numbers
Network Byte Order
Creating a Socket
Server-Side Functions
Naming a Socket
Waiting for Connections
Accepting Connections
Client-Side Functions
Connecting to a Server
Transferring Data
Destroying the Communications Channel
Putting It All Together
Other Functions
Socket "Names’’
Socket Options
Address Conversion
The Berkeley "r’’ Commands
The inetd Super-Server
Chapter Summary
Chapter 15 - - Networking with TLI
Overview
The netbuf Structure
Network Selection
The Network Configuration Library
The NETPATH Library
Network Selection in HP-UX 10.x
Name-to-Address Translation
Name-to-Address Translation in HP-UX 10.x
TLI Utility Functions
Transport Endpoint Management
Creating a Transport Endpoint
Binding an Address to a Transport Endpoint
Closing a Transport Endpoint
Transport Endpoint Options
Connectionless Service
Connection-Oriented Service
Server-Side Functions
Client-Side Functions
Transferring Data
Connection Release
Other Functions
Transport Endpoint Names
Connection State
Asynchronous Events
Address Conversion
Using read and write with TLI
Chapter Summary
Chapter 16 - - Miscellaneous Routines
Overview
Exiting When Errors Occur
Error Logging
Searching
Linear Search
Binary Search
Hash Tables
Binary Trees
Queues
Sorting
Environment Variables
Passwords
Random Numbers
Directory Trees
Database Management
Porting Notes
Pattern Matching
Shell Pattern Matching
Regular Expressions
Porting Notes
Internationalization
Defining the Locale
Formatting Numbers
Collating Sequences
Chapter Summary
Appendix A - - Significant Changes in ANSI C
Overview
Tokens
String Concatenation
Escape Sequences
The Preprocessor
String Substitution
Character Constants
Token Pasting
The #elif Directive
The #error Directive
Predefined Symbols
Text After #else and #endif
Declarations
The void Type
The enum Type
The char Type
Type Qualifiers
Functions
Function Prototypes
Widened Types
Expressions
Summary
Appendix B - - Accessing Filesystem Data Structures
Overview
The Mounted Filesystem Table
The Filesystem Defaults File
Obtaining Filesystem Statistics
Reading Filesystem Data Structures
Disk Terminology
The Super Block
I-Nodes
Cylinder Groups
Putting it All Together
Summary
Appendix C - - The /proc Filesystem
Overview
Obtaining Process Status
Obtaining Process Information
Obtaining Process Resource Usage
An Example
Summary