📄 00000009.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: Leeward (X 14% completed), 信区: Linux <BR>标 题: FireBirdBBS 精华区数据 HTML 化并打包成 tgz <BR>发信站: BBS 水木清华站 (Sun Jun 14 18:04:51 1998) <BR> <BR>补充说明:使用方式:Xhtml 精华区目录名 <BR> 运行成功时,生成的 tgz 文件位于程序中的 WORKDIR 下。 <BR> <BR>/* Making the X of a board into HTML format and then tar, gzip -- compress. */ <BR>/* */ <BR>/* Leeward 1998.02.17 (Modified 1998.05.22) */ <BR>/* */ <BR>/* This little program scans a X directory for a board */ <BR>/* and converts all its files into HTML format new files */ <BR>/* and finally compress the new into a UNIX tgz format package. */ <BR>/* */ <BR>/* This program uses shell command "ls -AFR" to get a temp control file of */ <BR>/* all X directory files, and then convert the recursive directory structure */ <BR>/* into a linear structure. */ <BR>/* */ <BR>/* Also this program duplicates all source files and renames all of them */ <BR>/* into digital MS-DOS 8.3 format file names (avoiding easily re-produce). */ <BR>/* */ <BR>/* Build: */ <BR>/* make Xhtml */ <BR>/* */ <BR>/* Known shortcomings: do not check if disk space is enough */ <BR>/* */ <BR> <BR>#include <stdio.h> <BR>#include <string.h> <BR>#include <sys/mode.h> <BR> <BR> <BR>#define MAXLINELEN 8192 <BR>#define MAXPATHLEN 256 <BR>#define MAXFILENUM 1024 /* max directories/files in a directory */ <BR> <BR>#define DOTNAMES ".Names" <BR>#define INDEXTMP "index.tmp" <BR>#define INDEXHTML "index.htm" <BR>#define HEADER "BBS水木清华站∶精华区" <BR>#define FOOTER "BBS水木清华站∶精华区" <BR> <BR>/* Leeward 98.05.22: Use another fixed disk as run-time working directorry; <BR> Do NOT use BBS' data disk space! */ <BR>/*#define WORKDIR "/opt/bbsbackup"*/ <BR>#define WORKDIR "." /* hehe, since 2GB disk recovered, not using /opt */ <BR> <BR> <BR>int <BR>main(int argc, char **argv) <BR>{ <BR> char srcLine[MAXLINELEN] = "", dstLine[MAXLINELEN] = ""; <BR> char srcDir[MAXPATHLEN] = "", dstDir[MAXPATHLEN] = ""; <BR> char srcFile[MAXPATHLEN] = "", dstFile[MAXPATHLEN] = ""; <BR> char srcX[MAXPATHLEN] = "", dstX[MAXPATHLEN] = ""; <BR> char anchor[MAXLINELEN] = ""; <BR> char Buf[MAXLINELEN] = "", Buf2[MAXLINELEN] = ""; <BR> char srcFX[MAXFILENUM][MAXPATHLEN], dstFX[MAXFILENUM][MAXPATHLEN]; <BR> char srcDX[MAXFILENUM][MAXPATHLEN]; <BR> char srcD[MAXPATHLEN], dstD[MAXPATHLEN]; <BR> char cwD[MAXPATHLEN] = ""; <BR> <BR> char *ptr; <BR> <BR> FILE *psrcFile, *pdstFile; <BR> FILE *pDOTNames; <BR> FILE *pINDEXhtml; <BR> FILE *pHasDOTNames; <BR> FILE *pls_AFR; <BR> <BR> int NumDir = 0, NumFile = 0; <BR> int NOTsrcX = - 1; <BR> int i, j, k; <BR> <BR> time_t now; <BR> <BR> <BR> printf("This application creates compressed HTML package for BBS.\n"); <BR> <BR> <BR> printf("Initializing...\n"); <BR> if (argc < 2) <BR> { <BR> printf("Syntax: %s XDIR\n", argv[0]); <BR> exit(-1); <BR> } <BR> <BR> strcpy(srcX, argv[1]); <BR> getcwd(cwD, MAXPATHLEN); <BR> if (chdir(srcX)) <BR> { <BR> printf("XDIR \"%s\" not found\n", srcX); <BR> exit(-1); <BR> } <BR> else <BR> { <BR> chdir(cwD); <BR> sprintf(dstX, "%s/%s.AIX", WORKDIR, srcX); <BR> if (mkdir(dstX, 0000755)) /* drwxr-xr-x */ <BR> { <BR> printf("Unexpected error: Can not create directory \"%s\"\n", dstX); <BR> exit(-2); <BR> } <BR> <BR> strcpy(srcDir, srcX); <BR> sprintf(srcDX[NumDir ++], "%s", srcDir); <BR> } <BR> <BR> sprintf(Buf, "ls -AFR %s > %ld.Xhtml", srcX, now = time(0)); <BR> system(Buf); <BR> sprintf(Buf, "echo Terminator\":\" >> %ld.Xhtml", now); /* NOT lack last */ <BR> system(Buf); <BR> <BR> <BR> printf("X Starting...\n"); <BR> sprintf(Buf, "%ld.Xhtml", now); <BR> if (NULL == (pls_AFR = fopen(Buf, "rt"))) <BR> { <BR> printf("Unexpected error: Can not open control file\n"); <BR> exit(-3); <BR> } <BR> printf("Processing directory \"%s\"...\n", srcDir); <BR> <BR> while (!feof(pls_AFR)) <BR> { <BR> fgets(Buf, MAXLINELEN, pls_AFR); <BR> if (feof(pls_AFR)) <BR> break; <BR> else <BR> Buf[strlen(Buf) - 1] = 0; <BR> <BR> if ('/' == Buf[strlen(Buf) - 1]) <BR> { /* directory */ <BR> Buf[strlen(Buf) - 1] = 0; <BR> sprintf(srcDX[NumDir ++], "%s/%s", srcDir, Buf); <BR> if (NumDir >= MAXFILENUM) <BR> { <BR> printf("Fatal error: direcotry number in this X exceeds %s\n", MAXFILENUM); <BR> fclose(pls_AFR); <BR> exit(-3); <BR> } <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -