- 博客(0)
- 资源 (22)
- 收藏
- 关注
GNU/Linux Application Programing second Edition (PDF)
GNU/LINUX
APPLICATION PROGRAMMING
SECOND EDITION
M. TIM JONES
This book was written with GNU/Linux application developers in mind. You’ll
note that topics such as the Linux kernel or device drivers are absent. This was
intentional, and while they’re fascinating topics in their own right, they are
rarely necessary to develop applications and tools in the GNU/Linux environment.
This book is split into five parts, each focusing on different aspects of GNU/Linux
programming. Part I, “Introduction,” introduces GNU/Linux for the beginner. It
addresses the GNU/Linux architecture, a short introduction to the process model and
also licenses, and a brief introduction to open source development and licenses. Linux
virtualization is also explored, including models and options in Linux.
Part II, “GNU Tools,” concentrates on the necessary tools for GNU/Linux pro-
gramming. The de facto standard GNU compiler tool chain is explored, along with
the GNU make automated build system. Building and using libraries (both static
and dynamic) are then investigated. Coverage testing and profiling are explored,
using the gcov and gprof utilities, as is application bundling and distribution with
automake and autoconf. Finally, source control is reviewed with some of the popu-
lar options on Linux and also data visualization with Gnuplot.
With an introduction to the GNU/Linux architecture and necessary tools for ap-
plication development, we focus next in Part III, “Application Development Topics,”
on the most useful of the services available within GNU/Linux. This includes pipes,
Sockets programming, dealing with files, both traditional processes and POSIX
threads, message queues, semaphores, and finally shared memory management.
In Part IV, “GNU/Linux Shells and Scripting,” we move up to application devel-
opment using shells and scripting languages. Some of the most useful GNU/Linux
commands that you’ll encounter in programming on GNU/Linux are covered, and
there is a tutorial on the Bourne-Again Shell (bash). Text processing is explored using
two of the most popular string processing languages (awk and sed). We’ll also look
at the topic of parser generation using GNU Flex and Bison utilities (lex and yacc-
compatible parser generator). Scripting with Ruby and Python is investigated as well.
In Part V, “Debugging and Testing,” debugging is addressed using a variety of
different aspects. We investigate some of the unit-testing frameworks that can help
in automated regression. The GNU Debugger is introduced, with treatment of the
most common commands and techniques. Finally, the topic of code hardening is
explored along with a variety of debugging tools and techniques to assist in the de-
velopment of reliable and secure GNU/Linux applications.
While the book was written with an implicit order in mind, each chapter can be
read in isolation, depending upon your needs. Where applicable, references to
other chapters are provided if more information is needed on a related topic.
Contents
Acknowledgments xiii
About the Author xv
Reader’s Guide xvii
Introduction xix
Part I Introduction 1
1 GNU/Linux History 3
Introduction 3
History of the UNIX Operating System 3
GNU/Linux History 5
Linux Distributions 7
Summary 8
References 8
2 GNU/Linux Architecture 9
9
Introduction
High-Level Architecture 9
Linux Kernel Architecture 10
Summary 18
Resources 18
3 Free Software Development 19
Introduction 19
Open Source Licenses 21
Problems with Open Source Development 23
Summary 24
References 25
Resources 25
4 Linux Virtualization and Emulation 27
Introduction 27
What Is Virtualization? 28
Short History of Virtualization 29
What’s the Point? 31
Virtualization Taxonomy 32
Open Source Virtualization Solutions 37
Summary 42
Part II GNU Tools 43
5 The GNU Compiler Toolchain 45
Introduction 45
46
Introduction to Compilation
GCC Optimizer 51
56
Debugging Options
Other Tools 56
Summary 57
59
6 Building Software with GNU make
Introduction 59
Makefile Variables 64
Summary 71
7 Building and Using Libraries 73
Introduction 73
What Is a Library? 73
Building Static Libraries 75
Building Shared Libraries 82
Dynamically Loaded Libraries 83
Utilities 88
Summary 92
Dynamic Library APIs 92
93
8 Building Packages with automake/autoconf
Introduction 93
Summary 103
9 Source Control in GNU/Linux 105
Introduction 105
Defining Source Control 105
Source Control Paradigms 106
Useful Source Control Tools 108
Summary 127
10 Data Visualization with Gnuplot 129
Introduction 129
Gnuplot 129
Summary 143
Resources 143
145
Part III Application Development Topics
11 File Handling in GNU/Linux 149
Introduction 149
File Handling with GNU/Linux 149
File Handling API Exploration 150
168
Base API
Summary 171
171
File Handling APIs
12 Programming with Pipes 173
Introduction 173
173
The Pipe Model
Detailed Review 176
Summary 184
Pipe Programming APIs 184
185
13 Introduction to Sockets Programming
Introduction 185
Layered Model of Networking 186
Sockets Programming Paradigm 186
Sample Application 191
Sockets API Summary 197
Other Transport Protocols 207
Multilanguage Perspectives 209
Summary 211
Sockets Programming APIs 212
References 213
Resources 213
14 GNU/Linux Process Model 215
Introduction 215
215
GNU/Linux Processes
Whirlwind Tour of Process APIs 216
Traditional Process API 226
System Commands 247
Summary 250
Proc Filesystem 250
References 252
API Summary 252
POSIX Threads (pthreads) Programming 253
15
Introduction 253
The pthreads API 256
Building Threaded Applications 274
Summary 275
References 275
API Summary 276
16 IPC with Message Queues 277
Introduction 277
Quick Overview of Message Queues 278
The Message Queue API 284
User Utilities 298
Summary 299
Message Queue APIs 300
17 Synchronization with Semaphores 301
Introduction 301
301
Semaphore Theory
Quick Overview of GNU/Linux Semaphores 304
The Semaphore API 313
User Utilities 327
Summary 329
Semaphore APIs 329
18 Shared Memory Programming 331
Introduction 331
Quick Overview of Shared Memory 332
Shared Memory APIs 339
Using a Shared Memory Segment 350
User Utilities 356
Summary 357
References 357
Shared Memory APIs 357
19 Advanced File Handling 359
Introduction 359
Enumerating Directories 364
Summary 375
Advanced File Handling APIs 375
20 Other Application Development Topics 379
Introduction 379
Linux Error Reporting 396
399
Summary
API Summary 399
Part IV GNU/Linux Shells and Scripting 401
21 Standard GNU/Linux Commands 405
Introduction 405
Redirection 405
Summary 422
423
22 Bourne-Again Shell (Bash)
423
Introduction
bash Scripting 425
Conditional Structures 430
Looping Structures 437
Input and Output 441
Functions 442
Sample Scripts 444
Scripting Language Alternatives 449
Summary 449
Resources 449
451
23 Editing with sed
Introduction 451
Anatomy of a Simple Script 452
sed Spaces (Buffers) 454
Typical sed Command-Line Options 454
Regular Expressions 455
Ranges and Occurrences 456
Essential sed Commands 457
Summary 460
Some Useful sed One-Liners 461
Resources 461
463
24 Text Processing with awk
Introduction 463
464
Command-Line awk
468
Scripted awk
Other awk Patterns 472
Summary 473
Useful awk One-Liners 474
Parser Generation with flex and bison 475
25
Introduction 475
A Simple Grammar 483
483
Encoding the Grammar in bison
Hooking the Lexer to the Grammar Parser 486
Building a Simple Configuration Parser 489
The Big Picture 493
Summary 497
26 Scripting with Ruby 499
Introduction 499
An Introduction to Ruby 499
Quick Ruby Examples 501
Language Elements 503
Advanced Features 513
Ruby as an Embedded Language 518
Summary 518
Resources 518
27 Scripting with Python 519
Introduction 519
An Introduction to Python 519
Quick Python Examples 522
Language Elements 525
Advanced Features 535
Summary 539
Resources 539
28 GNU/Linux Administration Basics 541
541
Introduction
Navigating the Linux Filesystem 541
Package Management 542
Kernel Upgrades 550
Summary 554
Part V Debugging and Testing 555
29 Software Unit Testing Frameworks 557
Introduction 557
Unit Testing Frameworks 560
Summary 576
Resources 576
30 Debugging with GDB 577
Introduction 577
Using GDB 578
Other GDB Debugging Topics 587
Summary 592
Resources 592
31 Code Hardening 593
Introduction 593
Code Hardening Techniques 594
Source Checking Tools 602
Code Tracing 603
Summary 605
Resources 605
607
32 Coverage Testing with GNU gcov
Introduction 607
What Is gcov? 607
Preparing the Image 608
Using the gcov Utility 609
615
Options Available for gcov
Considerations 616
Summary 617
References 617
Resources 617
619
33 Profiling with GNU gprof
Introduction 619
What Is Profiling? 619
What Is gprof? 620
Preparing the Image 620
Using the gprof Utility 622
Considerations 629
Summary 629
References 629
34 Advanced Debugging Topics 631
Introduction 631
Memory Debugging 631
Cross-Referencing Tools 639
641
System Call Tracing with ltrace
Dynamic Attachment with GDB 644
Summary 646
Resources 647
Appendix A Acronyms and Partial Acronyms 649
Appendix B About the CD-ROM 653
Index 655
2010-02-22
emacs 配置文件
emacs 配置文件(已经测试适合Windows和Linux),已经包含了各个扩展,主要的功能:
基本功能:
1. 设置colortheme
2. 共享系统剪贴板
3. 显示括号匹配
4. 用y-n取代yes-no
5. 用法高亮
6. 显示时间
7. 自动保存session,下次打开接着上次打开到文件
设置好了muse,包括彩色代码
编程:
1. auto-header, 自动添加文件头
2. 代码折叠
3. 2个空格到缩进方式
4. 开启光标在哪个函数的显示
键绑定:
1. M-g 跳到指定行
2. F2 set-mark-command
3. F3 dired
4. M-s speedbar
5. F10 列举书签
6. M-o 切换到其他窗口
7. F7 compile
增加了Eim输入法,这个解决了一些无法输入中文的问题
另外说说在windows下的使用,
1. 设置%HOME%环境变量
“我的电脑->属性”那边设置,记得重启电脑。检验设置成功的方法是在“运行”中输入%HOME%会打开设置的文件夹。
2. 把下载的文件放在%HOME%目录中
3. 直接可以绑定快捷键启动,比如:Alt-Ctrl-E
就这么简单。
2009-11-23
《TCPIP协议内核源码分析》正式版上册 pdf
《TCPIP协议内核源码分析》正式版上册,里面有中文注释,看了一下,觉得很不错,共享出来给大家。
上册目录:
第一章 从一个练习开始.................................第4页
第二章 TCP/IP的socket创建.............................第11页
第三章 TCP/IP的socket地址设置.........................第38页
第四章 TCP/IP的路由初始化.............................第66页
第五章 TCP/IP的路由设置过程...........................第94页
第六章 TCP/IP的socket地址绑定.........................第139页
第七章 TCP/IP的socket地址监听.........................第150页
第八章 TCP/IP的socket接收连接.........................第162页
2009-08-04
嵌入式Linux应用程序开发详解
嵌入式Linux应用程序开发详解-第1 章 Linux 快速入门.pdf
嵌入式Linux应用程序开发详解-第2 章 Linux 基础命令.pdf
嵌入式Linux应用程序开发详解-第3 章 Linux 下的C 编程基础.pdf
嵌入式Linux应用程序开发详解-第4 章 嵌入式系统基础.pdf
嵌入式Linux应用程序开发详解-第5 章 嵌入式Linux开发环境的搭建.pdf
嵌入式Linux应用程序开发详解-第6 章 文件IO编程.pdf
嵌入式Linux应用程序开发详解-第7 章 进程控制开发.pdf
嵌入式Linux应用程序开发详解-第8 章 进程间通信.pdf
嵌入式Linux应用程序开发详解-第9章(多线程编程).pdf
嵌入式Linux应用程序开发详解-第10章(嵌入式Linux网络编程).pdf
嵌入式Linux应用程序开发详解-第11章(嵌入式Linux设备驱动开发).pdf
嵌入式Linux应用程序开发详解-第12章(Qt图形编程).pdf
由于包比较大,采用.tar.bz2类型的压缩.压缩包绝对没有问题,我自己曾经下来解压.由于没有windows系统,不知道windows下能不能解压,如果在windows下不能解压,请给我发mail,(shuanghan.yang#gmail.com),请著名您的用户名.
另外提醒大家,既然下决心要学Linux,起码也得装个LInux操作系统(建议安装Ubuntu)。学游泳就得下水。
2009-06-12
Vim 配置包括所有的配置文件和扩展 适合windows linux
这个配置是根据网上“最N vim配置“修正了一些错误和增加了一些我认为方便的设置,功能确实很强,感谢Amix,本人保留他(她)的说明,里面的配置都有说明,很容易就懂,建议大家好好去看一遍,包你有长进。
运行环境
ubuntu 9.04 i686(8.10 64位也OK)
vim 7.2
部分功能说明:
1。打开的文件列在右边窗口
2。通过方向键切换打开的文档,
相当于:bn,:bp
3。底端有个mini窗口,类似emacs
4。支持tab自动补全
包括用:e打开文件是的文件名补全和关键字的自动补全
5。显示行号
6。指定字体
7。F11全屏
windows下才有效,因为我使用Linux,所以给注释掉,如果你使用的是windows请取消.vimrc 148行的注释 然后复制gvimfullscreen.dll到windows/system32或者winnt/system32下。
8。html标签自动完成
比如输入<html>自动完成</html>并且自动缩进
9。php的调试。(windows下有效)
编写好php以后,:make 运行PHP程序
:cl 显示错误提示包括行号,enter以后还会定位到出错行
:cl! 显示执行结果
嘿嘿,很不错吧。我用起来很不错
10。对从c/c++文件自动生成说明文档
11。空格(space)为查找相当于/
12. 自动加载vim配置文件
。。。还有很多自己可以去看里面的.vimrc内容,当然也建议你去读一遍里面的内容,有新大陆的发现记得留言告诉我和大家
安装步骤
Linux:
1。备份自己的配置
$ tar cjvf vim_bk.tar.bz2 ~/.vimrc ~/.vim #备份自己原有的配置,万一我的配置在你的系统上水土不服也好恢复嘛
2。请解压指自己的主目录
$ tar jxvf vim.tar.bz2 -C ~/ #解压缩到主目录
$ ls -al ~ #查看
3。建议浏览一下配置文件
vim ~/.vimrc
4。运行gvim就看看效果吧
gvim
Windows:
1。备份原有的设置,怎么备份就自己去弄吧
2。解压vim.tar.bz2(怎么解压,当然安装winrar,然后就双击)
3。压缩包里面.vim 对应$VIMRUNTIME/vimfiles,$VIMRUNTIME,就是vim的安装目录啦,默认安装在c:\program files/Vim
4。改.vimrc 为_vimrc
有任何指教,意见,批评等请发伊妹儿 michael.yang2000#gmail.com.
2009-06-04
[Linux英文原版图书系列].Slackware.Linux.Essentials.pdf
Slackware是一个很优秀的发行版本,我大学的旧笔记本电脑(CPU:奔腾133,内存:128M,硬盘:2G)装的就是Slackware 11.0 运行很好,用写Python,阅读资料.
2009-05-13
Gedit 插件 主要对python的编写做了优化
这是自己使用的Gedit的插件,主要对Python的编写做了优化,打包一起方便大家下载,不用一个一个去找,里面包含:
1。project manager 项目管理
2。class browser
3。find in document 多文档里查找内容
4。python indent 针对python的智能缩进
5。file browser
6。html-tidy
7。advanced-bookmarks 高级书签
8。betterpythonconsole
9。run in python Ctrl+F5 运行python代码
10。word complete 自动完成代码,方便快速输入
等等很常用,很不错的插件。
里面还包含了一个很不错的配色方案。
安装的方法很简单都写在里面的Readme文件里面
希望对有需要的人有帮助
2009-02-06
Linux下远程连接windows3389端口
使用过windows的远程桌面的朋友都知道,windowsxp以上的操作系统都有远程桌面的功能,这个软件就是让Linux方便的连接windows 远程桌面。希望这个软件能给需要的人带来方便。
2009-02-06
BOA Constructor 教程
BOA Constructor是Python 下用GTK进行图形编程的软件,界面很象Delphi.
Getting Started Guide for boa Constructor
boa constructor 教程
2009-02-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人