FTP列表格式 [英] FTP List format

查看:103
本文介绍了FTP列表格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个嵌入式ftp服务器,我无法正确获取列表格式。服务器完全工作,只有像FileZilla这样的程序无法解释列表格式。下面是一个示例列表:

  -rwxr  -  r-- 1个所有者组640 1970 01 01 test 
-rwxr --r-- 1个所有者组13440 1970 01 01 test.html
-rwxr - r-- 1个所有者组512 1970 01 01 test2.txt

其中基本上是:

 权限[tab] number?[ tab] owner [tab] group [tab] filesize [tab] date [tab] filename 

什么是我做错了?



谢谢,
Yvan

解决方案

正如其他人已经提到的,你需要使用空格而不是制表符。这是另一个应该可以工作的嵌入式FTP服务器的sprintf:

  sprintf(line,%s 1%-10s%-10s %10lu 1980年1月1日%s \ r \ n,
permstr,用户名,用户名,
长度,
文件名);

permstr 被设置为像 - rw-rw-rw -



至于日期格式,这两个应该可以工作,如果日期超过6个月,则使用:

  if(dfmt)
sprintf(buf,%3.3 s%2d%04d,month_name,month_num,year);
else
sprintf(buf,%3.3s%2d%02d:%02d,month_name,month_num,hour,minute);


I'm writing an embedded ftp server, and I cannot get the listing format correctly. The server works completely, only programs like FileZilla cannot interpret the listing format. Here's a sample listing:

-rwxr--r--  1   owner   group 640   1970 01 01  test
-rwxr--r--  1   owner   group 13440 1970 01 01  test.html
-rwxr--r--  1   owner   group 512   1970 01 01  test2.txt

Which is basically:

permissions[tab]number?[tab]owner[tab]group[tab]filesize[tab]date[tab]filename 

What am I doing wrong?

Thanks, Yvan

解决方案

As others have already mentioned, you need to use spaces instead of tabs. Here's a sprintf from another embedded FTP server that should work:

sprintf(line, "%s   1 %-10s %-10s %10lu Jan  1  1980 %s\r\n",
    permstr, username, username,
    length,
    filename);

permstr is set to a string like "-rw-rw-rw-".

As for date formats, these two should work, with the top used if the date is more than 6 months old:

if (dfmt)
    sprintf(buf, "%3.3s %2d  %04d", month_name, month_num, year);
else
    sprintf(buf, "%3.3s %2d %02d:%02d", month_name, month_num, hour, minute);

这篇关于FTP列表格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆