Windows System Programming Third Edition



Download 3.41 Mb.
Page27/31
Date31.07.2017
Size3.41 Mb.
#24970
1   ...   23   24   25   26   27   28   29   30   31

Web Site Organization


The primary directory is named WindowsSmpEd3 ("Windows Sample Programs, Edition 3"), and this directory can be copied directly to your hard disk. There is a subdirectory for each chapter. All include files are in the Include directory, and the Utility directory contains the commonly used functions such as ReportError and PrintStrings. Complete projects are in the Projects6 and Projects7 directories (Visual C++ 6.0 and 7.0, respectively). Executables and DLLs for all projects are in the run6 and run7 directories. The TimeTest directory contains files required to run the performance tests described in Appendix C. Before describing the individual WindowsSmpEd3 subdirectories, other Web site contents should be mentioned.

Instructional Overheads (Slides)


The Overheads directory contains a set of PowerPoint slides. The slides are included for the convenience of college and university faculty who might wish to use the book in a course. The slides are not intended for commercial purposes.

The Utility Directory


The Utility directory contains seven source files for utility functions required by the sample programs.

  1. ReprtErr.c contains the functions ReportError (Program 2-2) and ReportException (Program 4-1). Every program executed as a process by other sample programs requires this file, except for the grep and wc programs and those in Chapter 1.

  2. PrintMsg.c contains PrintStrings, PrintMsg, and ConsolePrompt (Program 2-1). ReprtErr.c calls these functions, so this source file is also required in nearly every project.

  3. Options.c contains the function that processes command line options and is used frequently starting in Chapter 2. Include this source file in the project for any program that has command line options. The listing is Program A-7.

  4. Wstrings.c contains the source code for the wmemchr function used by Options.c. Include this file as necessary. You may find it convenient to add other generic string processing functions.

  5. SkipArg.c processes a command line by skipping a single argument field with each call. It is listed in Program A-8.

  6. GetArgs.c converts a character string into the argc, argv [] form. This function is useful when parsing a command line into individual arguments, such as the command line obtained from the GetCommandLine function introduced in Chapter 6. The listing is Program A-8.

  7. Version.c implements the DllGetVersion function for the DLL built from these modules.

The functions can be compiled and linked with the calling program. You will find it easiest, however, to build them as a library, either static or dynamic. The Utility_3_0 project builds a DLL from these source files, while utilityStatic is the project that creates a static library.

The Include Directory


Numerous header files are defined in the Include directory. Some of these files are used by nearly all the examples, whereas others are specific to one or two programs. The most important files are the following.

  1. EvryThng.h, as the name suggests, brings in nearly everything required for normal programs, whether single-threaded or multithreaded. In particular, it includes the files Envirmnt.h and Support.h. The listing is Program A-1.

  2. Exclude.h defines a number of preprocessor variables that exclude definitions not required by any of the programs in this book. This arrangement speeds compilation and reduces the size of the precompiled header files.

  3. Envirmnt.h defines the UNICODE and _UNICODE preprocessor variables consistently as well as the language and sublanguage used by ReportError. Program A-2 lists this file.

  4. Support.h defines many of the common functions, such as ReportError, as well as a variety of frequently used symbolic constants. Program A-3 shows this file.

  5. ClntSrvr.h is used beginning in Chapter 11. It defines the request and response message structures, client and server named pipes and mailslots, time-out values, and so on. See Program A-5.

  6. JobMgt.h is used in the job management programs at the end of Chapter 6. See Program A-4.

Programs by Chapter


Each chapter directory contains all the programs in that chapter (except for the programs in the Utility directory) as well as miscellaneous additional programs. The programs are listed here, with brief descriptions of the additional programs. You will also find a number of programs with an x suffix; these programs contain deliberate defects that illustrate common programming errors.

Note: Many programs, such as tail and touch in Chapter 3, have names that are identical to the UNIX utilities they mimic. You may wish to rename them with names such as tailW and touchW to avoid confusion. Several programs have already been renamed; lsW and cpW are examples.


Chapter 1

  • cpC.c is Program 1-1.

  • cpW.c is Program 1-2; cpwFA.c shows the code modified for better performance. See the results in Appendix C.

  • cpCF.c is Program 1-3.

  • Other programs include a UNIX version (cpU.c) and one (cpUC.c) built to use the UNIX compatibility library provided with Visual C++. CpwFA.c is a cpW.c variation designed to be faster using large buffers, sequential scan flags, and other techniques introduced in Chapter 2.
Chapter 2

  • Programs 2-1 and 2-2 are in the Utility directory, which was described earlier.

  • cat.c is Program 2-3.

  • atou.c is Program 2-4.

  • Asc2Un.c is Program 2-5; Asc2UnFA.c and Asc2UnNB.c are performance-enhanced versions. All three files implement the Asc2Un function called by Program 2-5.

  • pwd.c is Program 2-6; pwda.c is modified to allocate the required memory for the pathname.

  • cd.c is an implementation of the UNIX directory change command; it is not an example in Chapter 2.
Chapter 3

  • RandomAccess.c is Program 3-1.

  • lsW.c is Program 3-2. rmW.c is a similar program to remove files.

  • touch.c is Program 3-3.

  • getn.c is an additional program that reads a specified fixed-size record, illustrating file access and computing file positions.

  • lsReg.c is Program 3-4.

  • FileSize.c is an exercise solution that determines whether or not file space is allocated sparsely.

  • TestLock.c exercises file locking.

  • tail.c is required as part of Exercise 33.
Chapter 4

  • Program 4-1 is part of ReprtErr.c in the Utility directory.

  • toupper.c is Program 4-2. toupperX.c has several intentional errors; fixing them would be a good exercise.

  • Excption.c is Program 4-3 and contains a filter function, Program 4-4.

  • Ctrlc.c is Program 4-5.
Chapter 5

  • sortBT.c represents Program 5-1 and 5-2; sortBTSR.c omits the no-serialization option on memory management calls to determine whether there is any performance impact in a simple application. The reader can verify that there is very little effect.

  • Asc2UnMM.c is the function for Program 5-3.

  • sortFL.c is Program 5-4, and sortHP.c is a similar program except that it reads the file into an allocated memory buffer rather than using mapped memory.

  • sortMM.c is Program 5-5 and 5-6.

  • atouEL.c is Program 5-7, and Asc2UnDll.c and Asc2UnmmDLL.c are the source files for the required DLLs. Asc2Unmmfl.c is yet another variation that flushes memory on completion, which may slow overall execution but leaves the system in a safe state.

  • HeapNoSr.c is a test program that measures the effect of memory allocation with and without the HEAP_NO_SERIALIZE flag. This program can be used with Exercise 51.

  • RandFile.c generates randomly keyed text files of any specified size; these files are suitable for testing the sorting functions and are also used to generate large text files for many of the timing tests.

  • clear.c is a simple program that allocates and initializes virtual memory in large units, continuing until failure. This program is used between timing tests to ensure that data is not cached into memory, which could distort the measurements.
Chapter 6

  • grepMP.c is Program 6-1. grep.c is the source for a C librarybased pattern search program to be invoked as a process by grepMP.c.

  • timep.c is Program 6-2.

  • JobShell.c is Program 6-3, and JobMgt.c provides the support functions of Program 6-4, 6-5, and 6-6.

  • catHA.c and grepMPha.c are modified versions of other programs designed to show how to pass a handle on the command line, solving Exercise 62.

  • version.c obtains information, including the version number, about the operating system.
Chapter 7

  • grepMT.c is Program 7-1. grepMTx.c is intentionally defective; fixing it is Exercise 77.

  • sortMT.c is Program 7-2. sortMTx.c is intentionally defective.

  • wcMT.c solves Exercise 76. There are two versions with intentional defects, and another version that serializes file processing for timing comparison.

The corresponding projects all use the multithreaded C library, as described in the chapter.
Chapter 8

  • simplePC.c is Program 8-1.

  • eventPC.c is Program 8-2.
Chapter 9

  • statsMX.c is Program 9-1. Variations are statsNS.c, statsCS.c, and statsIN.c.

  • TimedMutualExclusion.c is used for timing studies suggested in the text and the exercises.
Chapter 10

  • Program 10-1 contains part of SynchObj.h, which is in the Include directory. Program 10-3 contains the rest.

  • ThbObject.c is Program 10-2. testTHB.c is the associated test program.

  • QueueObj.c is Program 10-4, and variations include QueueObjCS.c (uses a CRITICAL_SECTION), QueueObjSOAW.c (uses SignalObjectAndWait), and signal model versions.

  • ThreeStage.c is Program 10-5, and its project requires Messages.c and QueueObj.c.

  • QueueObjCancel.c is Program 10-6, and it works in conjunction with ThreeStageCancel.c.

  • MultiSem.c, along with the test program, TestMultiSem.c, is the solution to Exercise 1011.

  • MultiPCav.c uses Pthreads; converting it to use the Windows API, or, alternatively, using the open source Pthreads library, would be a useful exercise.
Chapter 11

  • pipe.c is Program 11-1. wc.c is used as a convenient command to demonstrate its operation. pipeNP.c is a variation using a named pipe.

  • clientNP.c is Program 11-2.

  • serverNP.c is Program 11-3.

  • SrvrBcst.c is Program 11-4.

  • LocSrver.c is Program 11-5.
Chapter 12

  • clientSK.c is Program 12-1.

  • serverSK.c is Program 12-2.

  • command.c is Program 12-3.

  • SendReceiveSKST.c is Program 12-4, and serverSKST.c and clientSKST.c are slight modifications of serverSK.c and clientSK.c for streaming I/O. SendReceiveSKST.c should be built as a DLL, and the DLL should be implicitly linked with the client and server projects.

  • SendReceiveSKHA.c is Program 12-5, and serverSKHA.c is the corresponding server that uses the DLL. ClientSKST.c will work with this server.
Chapter 13

  • SimpleService.c is Program 13-2 and includes all of Program 13-1.

  • ServiceShell.c is Program 13-3.

  • serviceSK.c is serverSK.c (Program 12-2) converted to a service.
Chapter 14

  • atouOV.c is Program 14-1.

  • atouEX.c performs the same task with extended I/O and is Program 14-2.

  • atouMT.c performs the same task with multiple threads rather than with Win32 asynchronous I/O. atouMT_dh.c is an incorrect version included to illustrate an interesting and risky feature of handle duplication.

  • atouMTCP.c uses I/O completion ports.

  • TimeBeep.c is Program 14-3.

  • serverCP.c, Program 14-4, is a version of serverMT that uses I/O completion ports and overlapped I/O.
Chapter 15

  • chmodW.c is Program 15-1, with features added to distinguish allowed and denied ACEs properly (as described in the text). chmodBSD.c is a variation that uses the BuildSecurityDescriptor function.

  • lsFP.c is Program 15-2.

  • InitUnFp.c is the code for Program 15-3, 15-4, and 15-5. Program 15-1 and 15-2 require these functions. The source module also contains code showing how to obtain the name of an owning group, which is Exercise 1512.

  • TestFp.c is an additional test program that was useful during testing.

  • serverNP_secure.c is Program 15-6.

  • JobShell_secure.c and JobMgt_secure.c are enhancements to the Chapter 6 job management system.
Chapter 16

There is only one source file, sortMM64.c, which is Chapter 5's sortMM.c enhanced to work under both Win32 and Win64.

Directory: bitstream -> NAU
bitstream -> A mathematical theory of communication
bitstream -> Images of Fairfax in Modern Literature and Film Andrew Hopper
bitstream -> Amphitheater High School’s Outdoor Classroom: a study in the Application of Design
bitstream -> Ethics of Climate Change: Adopting an Empirical Approach to Moral Concern
bitstream -> The Age of Revolution in the Indian Ocean, Bay of Bengal and South China Sea: a maritime Perspective
bitstream -> Methodism and Culture
bitstream -> Review of coastal ecosystem management to improve the health and resilience of the Great Barrier Reef World Heritage Area
bitstream -> Present state of the area
NAU -> International significance of icao alphabet for flight safety
NAU -> Performance comparison of android runtime and dalvik environments on an android device

Download 3.41 Mb.

Share with your friends:
1   ...   23   24   25   26   27   28   29   30   31




The database is protected by copyright ©ininet.org 2024
send message

    Main page