代码:
1 //This is c program code! 2 /* *=+=+=+=+* *** *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= 3 * 文档信息: *** :~/WORKM/stutyCode/linuxPrograming/manageDisk/diskManage.c 4 * 版权声明: *** :(魎魍魅魑)MIT 5 * 联络信箱: *** :guochaoxxl@163.com 6 * 创建时间: *** :2020年12月12日的上午10:43 7 * 文档用途: *** :数据结构与算法分析-c语言描述 8 * 作者信息: *** :guochaoxxl(http://cnblogs.com/guochaoxxl) 9 * 修订时间: *** :2020年第49周 12月12日 星期六 上午10:43 (第347天) 10 * 文件描述: *** :自行添加 11 * *+=+=+=+=* *** *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+*/ 12 13 /* 14 CD Database Application 15 16 Beginning Linux Programming 17 18 Version: Terminals 19 20 Copyright (c) 1996,2007 Wrox Press 21 22 This program is free software; you can redistribute it and/or modify 23 it under the terms of the GNU General Public License as published by 24 the Fee Software Foundation; either version 2 of the License, or (at 25 your option) any later version. 26 27 This program is distributed in the hopes that it will be useful, but 28 WITHOUT ANY WARRANTY; without even the implied warranty of 29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 General Public License for more details. 31 32 You should have received a copy of the GNU General Public License 33 along with this program; if not, write to the Free Software 34 Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. 35 36 */ 37 38 /* 39 Notes 40 41 This version of the CD database application has been written 42 using the information presented in the Terminals chapter. 43 44 It is derived from the shell script presented in the Shell 45 Programming chapter. It has not been redesigned for the C 46 implementation, so many features of the shell original can 47 still be seen in this version. 48 49 There are some problems with this implementation that will 50 be resolved in later revisions: 51 52 It does not deal with commas in titles. 53 It has a practical limit on tracks per CD to keep them on screen. 54 55 The program deliberately uses the standard input and output 56 file streams. It does not deal with re-directed input or 57 output explicitly. */ 58 59 #include <unistd.h> 60 #include <stdlib.h> 61 #include <stdio.h> 62 #include <string.h> 63 #include <curses.h> 64 65 66 #define MAX_STRING (80) /* Longest allowed response */ 67 #define MAX_ENTRY (1024) /* Longest allowed database entry */ 68 69 #define MESSAGE_LINE 6 /* Misc. messages go here */ 70 #define ERROR_LINE 22 /* The line to use for errors */ 71 #define Q_LINE 20 /* Line for Questions */ 72 #define PROMPT_LINE 18 /* Line for prompting on */ 73 74 /* 75 The variable current_cd is used to store the CD title we are 76 working with. It is initialized so that the first character is NUL 77 to indicate 'no CD selected'. The is strictly unnecessary, but 78 serves to emphasize the point. 79 80 The variable current_cat will be used to record the catalog number 81 of the current CD. 82 */ 83 84 static char current_cd[MAX_STRING] = "