文字MUD游戏论坛-天下泥潭群英会-水泊梁山  

返回   文字MUD游戏论坛-天下泥潭群英会-水泊梁山 > 西游之旅 > 『 巫师天下 』

『 巫师天下 』 学习如何挂MUD,如何制作MUD。讨论如何管理好一个MUD,做好一个巫师。

发表新主题 回复
 
LinkBack 主题工具 主题评分 显示模式
旧 2011-12-03   #1
高级会员
级别:6 | 在线时长:109小时 | 升级还需:31小时级别:6 | 在线时长:109小时 | 升级还需:31小时级别:6 | 在线时长:109小时 | 升级还需:31小时
 
Odysseus 的头像
 
注册: 08年04月11日
来自: 盘丝洞
帖子: 311
声望力: 20
声望: 50 Odysseus 初领妙道
现金:29两梁山币
资产:1245两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0
MUD FTP 服务器的修缮(下)

作者:jjgod  发表时间:2001年4月15日 09:08

--------------------------------------------------------------------------------

发信人: fof (格斗之迷~思考中), 信区: wiz
标 题: MUD FTP 服务器的修缮(下)
发信站: 交通大学思源BBS (Thu Nov 16 00:45:23 2000), 转信

我修改过的那两段程序如下:
……
case "size": // return size of file
……
case "nlst": // give name list of files in directory
CHECK_LOGIN();
/* Send name list */
if ((i = sizeof(command)) > 1 && command[1] == "-l") {
if (i == 2)
command[1] = ".";
else
command = ({ command[0] }) + command[2..s-1];
// and fall through to "list"
} else {
/* Used by commands like "dir", "mget", and "mput" */
if ( i > 1 )
tmp = get_path( fd, command[ 1 ] );
else
tmp = socket_info[ fd ][ CWD ];

if ( check_valid_read( tmp, fd ) ) {
tmp2 = ls( tmp, 1, fd );
if (tmp2 == "")
socket_write( fd, "550 No files found.\n" );
else
data_conn( fd, tmp2, "ls", STRING );
} else
PERMISSION_DENIED550(command[ 1 ]);
break;
}
case "list": // give list files in a directory
CHECK_LOGIN();
/* Send directory file list (like exec'ing "ls") */
if ((i = sizeof(command)) > 1 &&
(command[1] == "-L" || command[1] == "-a" &&
command[2] == "-L")) {
if (i == 2)
command[1] = ".";
else
command = ({ command[0] }) + command[2..s-1];
}
if ( sizeof( command ) > 1 )
tmp = get_path( fd, command[ 1 ] );
else
tmp = socket_info[ fd ][ CWD ];
if ( check_valid_read( tmp, fd ) ) {
tmp2 = ls( tmp, 0, fd );
if (tmp2 == "")
socket_write( fd, "550 No files found.\n");
else
data_conn( fd, tmp2, "ls", STRING );
} else
PERMISSION_DENIED550(command[ 1 ]);
break;
case "xpwd": // print the current working directory (deprecated)
……

修改后的 ls() 函数:
string ls( string path, int column, int fd ) {
string *files;
int i, j, s;
mixed *xfiles;
mixed *stats;
string tmp, tmp2, creator, domain;

/* if path is a directory get contents */
if ( directory_exists( path ) ) {
if ( path[ strlen( path ) - 1 ] == '/' )
path += "*";
else
path += "/*";
}

/* begin narrow columnar "nlst" */
if (column) {
files = get_dir( path );

/* can only happen if permissions are messed up at account level */
if (!files)
return "";

files -= ({ ".", ".." });

if (!(i = sizeof( files )))
return "";

/* no wild cards...must have been the exact pathname to a file */
if (strsrch(path, '*') == -1 && strsrch(path, '?') == -1) {
return files[0] + "\n";
}

/* remove globber at end of path, leave a trailing slash */
j = strsrch(path, '/', -1);
path = path[0..j];

while ( i-- ) {
/* scan next level down for files */
tmp = sprintf("%s%s/", path, files[i]);
if ( directory_exists( tmp ) ) {
files[i] += "/";
}
}
return implode( files, "\n" ) + "\n";
}

/* begin long "list" */
xfiles = get_dir( path, -1 );
if (!xfiles || !(s = sizeof( xfiles )))
return "";

files = allocate(s);

// the Unix-like file permissions are mainly for effect...hopefully it
// isn't too much, since anything more would likely be too cpu intensive
// and cause it to max eval...
creator = (string)MASTER_OB->creator_file(path);
if (!creator) creator = ROOT_UID;

domain = (string)MASTER_OB->domain_file(path);
if (!domain) domain = ROOT_UID;

i = strsrch(path, '/', -1);
if (i >= 0)
path = path[0..i];

for (i = 0; i < s; i++) {
/* process timestamp */
tmp2 = ctime((xfiles[i])[2]); /* get last modified timestamp */
if ((xfiles[i])[2] + SECS_IN_YEAR < time()) {
/* MMM DD YYYY */
tmp = sprintf("%s %s", tmp2[4..9], tmp2[20..23]);
} else {
/* MMM DD hh:mm */
tmp = tmp2[4..15];
}

j = (xfiles[i])[1]; /* get filesize */
if (j == -2) {
/* directory */
// files[i] = sprintf("drwxrwsr-x %12s %12s <DIR> %12s %s/",
files[i] = sprintf("drwxrwsr-x 1 %-8s %-8s 0 %12s %s",
creator, domain, tmp, (xfiles[i])[0]);
} else {
/* file */
stats = stat(path + (xfiles[i])[0]);
// files[i] = sprintf("-rw%crw-r-- %12s %12s %8d %12s %s",
files[i] = sprintf("-rw%crw-r-- 1 %-8s %-8s %12d %12s %s",
stats[2] ? 'x' : '-', /* 'x' if loaded, else ' ' */
creator, domain, j, tmp, (xfiles[i])[0]);
}
}

return sprintf( "%s\n", implode( files, "\n" ) );
}

Well, are you clear ?

后记:
在西游记2000版中,西游记巫师组对 FTP 服务器程序作了一些修缮,不过因为
没有去掉 "<DIR>" 这个不合标准的东东,CuteFTP 还是不能识别它传回的目录。
把 "<DIR>" 换成目录的字节 "0" 就行了,整个 ftpd.c 就改这一个地方就可以
适应 CuteFTP 了,弄一个试试吧!

(完)
Odysseus 当前离线  
回复时引用此帖

发表新主题 回复

添加到书签


发帖规则
不可以发表主师
不可以回复帖子
不可以上传附件
不可以编辑自己的帖子

论坛启用 vB 代码
论坛启用 表情图标
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用


相似的主题
主题 主题作者 论坛 回复 最后发表
MUD FTP服务器的修缮 Odysseus 『 巫师天下 』 0 2011-12-03 23:17
MUD FTP 服务器的修缮(上) Odysseus 『 巫师天下 』 0 2011-12-03 23:06
MUD FTP 服务器的修缮(中) Odysseus 『 巫师天下 』 0 2011-12-03 23:06
综合类FTP sandman 『 动漫影视下载专区 』 7 2004-10-22 21:59
勇FTP Csheng 『 动漫影视下载专区 』 6 2004-04-12 19:10


所有时间均为格林尼治时间 +9, 现在的时间是 12:09.


Powered by SPLS
版权所有 2001-2023 水泊梁山
皖ICP备05012024号

站长 fengyue

Content Relevant URLs by vBSEO 3.6.1