Algorithm 版 (精华区)
发信人: Lerry (想不开·撞树), 信区: Algorithm
标 题: makestat.c
发信站: 哈工大紫丁香 (2002年06月09日21:26:56 星期天), 站内信件
/*
* NoseyParker, the search engine for FTP archives
* Copyright (C) 1993-96 by Jiri A. Randus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* The author can be reached as follows:
* Internet: <Jiri.Randus@vslib.cz>
* Phone: ++42 48 5227374
* SnailMail: Jiri Randus
* KIN HF TU v Liberci
* Halkova 6
* 46117 Liberec
* Czech Republic
*/
#define MAKESTAT_VERSION "2.0"
#include "parker.h"
#include <dirent.h>
void main(void)
{
DIR *d;
FILE *f;
unsigned long Cnu=0;
char name[MAX];
char date[MAX];
struct dirent *ptr;
struct stat st;
if(!(d=opendir("."))) {
perror("Cannot open dir");
exit(101);
}
while((ptr=readdir(d))!=NULL)
{
if(!strncmp(ptr->d_name,EXCLUDEFILES,strlen(EXCLUDEFILES))) continue;
if(!strcmp(ptr->d_name,CORE)) continue;
if(*ptr->d_name=='.') continue;
strcpy(name,"./");
strcat(name,ptr->d_name);
if(!(f=fopen(name,"r"))) perror(ptr->d_name);
else {
if(stat(name,&st)) perror("stat");
strcpy(date,ctime(&st.st_mtime));
date[strlen(date)-1]='\0';
fseek(f,0L,SEEK_END);
strcpy(name,ptr->d_name);
Cnu++;
name[strlen(name)-3]='\0';
if(Cnu/2*2 == Cnu)printf("<tr><td bgcolor='#B0FFFF'><a href='ftp://%s'
>%s\n</a> </td><td> %s </td><td> %9lu </td></tr>",name,name,date,ftell(f));
else printf("<tr><td bgcolor='#FFB0FF'><a href='ftp://%s'>%s\n</a> </t
d><td> %s </td><td> %9lu </td></tr>",name,name,date,ftell(f));
fclose(f);
}
}
closedir(d);
}
--
当一个女孩儿觉得她不太容易了解那个男人的时候,她会爱他。
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.724毫秒