FTP List format

后端 未结 3 868
孤街浪徒
孤街浪徒 2021-02-10 03:39

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

3条回答
  •  心在旅途
    2021-02-10 03:50

    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);
    

提交回复
热议问题