65 lines
2.1 KiB
Plaintext

$OpenBSD: patch-compat,v 1.2 2000/09/21 08:49:32 camield Exp $
Output in /bin/ls format instead of EPLF. EPLF is not yet compatible
with some major FTP clients.
/bin/ls format complies with: http://cr.yp.to/ftp/list/binls.html
For information on EPLF see: http://cr.yp.to/ftp/list/eplf.html
Patch by Camiel Dobbelaar, <cd@sentia.nl>
--- fetch.c.orig Tue Nov 9 08:23:46 1999
+++ fetch.c Thu Sep 21 10:35:18 2000
@@ -40,24 +40,35 @@
static void printstat()
{
- substdio_puts(&ss,"+i");
- substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_dev));
- substdio_puts(&ss,".");
- substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_ino));
+ char *longstring;
+ int len;
- if (st.st_mtime > 0)
- if (st.st_mtime < now - 60) {
- substdio_puts(&ss,",m");
- substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_mtime));
- }
-
- if ((st.st_mode & S_IFMT) == S_IFDIR)
- substdio_puts(&ss,",/");
- if (((st.st_mode & S_IFMT) == S_IFREG) && ((st.st_mode & 0444) == 0444)) {
- substdio_puts(&ss,",r,s");
- substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_size));
+ /* rights, links, user, group */
+ if (((st.st_mode & S_IFMT) == S_IFREG) && ((st.st_mode & 0444) == 0444))
+ substdio_puts(&ss,"-rw-r--r-- 1 owner group ");
+ else if ((st.st_mode & S_IFMT) == S_IFDIR)
+ substdio_puts(&ss,"drwxr-xr-x 1 owner group ");
+ else {
+ substdio_puts(&ss,"---------- 1 owner group ");
+ /* do not reveal size, the EPLF implementation does not either */
+ st.st_size = 0;
}
- substdio_puts(&ss,",\t");
+
+ /* size */
+ len = fmt_ulong(strnum,(unsigned long) st.st_size);
+ /* right justify in 13-byte field */
+ substdio_put(&ss," ",((13-len) > 0) ? (13-len):0);
+ substdio_put(&ss,strnum,len);
+ substdio_puts(&ss," ");
+
+ /* date, time/year */
+ longstring = ctime(&st.st_mtime);
+ substdio_put(&ss,longstring+4,7);
+ if (st.st_mtime + ((365/2)*86400) > now)
+ substdio_put(&ss,longstring+11,5);
+ else
+ substdio_put(&ss,longstring+19,5);
+ substdio_puts(&ss," ");
}
static void list(char *fn,int flaglong)