-#include <sgtty.h>
-
-#define kbytes(size) (((size) + 1023) / 1024)
-
-struct afile {
- char ftype; /* file type, e.g. 'd', 'c', 'f' */
- ino_t fnum; /* inode number of file */
- short fflags; /* mode&~S_IFMT, perhaps ISARG */
- short fnl; /* number of links */
- short fuid; /* owner id */
- short fgid; /* group id */
- long fsize; /* file size */
- long fblks; /* number of blocks used */
- time_t fmtime; /* time (modify or access or create) */
- char *fname; /* file name */
- char *flinkto; /* symbolic link value */
-};
-
-#define ISARG 0x8000 /* extra ``mode'' */
-
-struct subdirs {
- char *sd_name;
- struct subdirs *sd_next;
-} *subdirs;
-
-int aflg, dflg, gflg, lflg, sflg, tflg, uflg, iflg, fflg, cflg, rflg = 1;
-int qflg, Aflg, Cflg, Fflg, Lflg, Rflg, Sflg;
-
-int usetabs;
-
-time_t now, sixmonthsago;
-
-char *dotp = ".";
-
-struct winsize win;
-int twidth;
-
-struct afile *gstat();
-int fcmp();
-char *cat(), *savestr();
-char *fmtentry();
-char *getname(), *getgroup();
-
-char *ctime();
-char *malloc(), *calloc(), *realloc();
-char *sprintf(), *strcpy(), *strcat();
+#include "ls.h"
+
+int (*sortfcn)(), (*printfcn)();
+int lstat(), strlen();
+char *emalloc();
+
+int termwidth = 80; /* default terminal width */
+
+/* flags */
+int f_accesstime; /* use time of last access */
+int f_column; /* columnated format */
+int f_group; /* show group ownership of a file */
+int f_ignorelink; /* indirect through symbolic link operands */
+int f_inode; /* print inode */
+int f_kblocks; /* print size in kilobytes */
+int f_listalldot; /* list . and .. as well */
+int f_listdir; /* list actual directory, not contents */
+int f_listdot; /* list files beginning with . */
+int f_longform; /* long listing format */
+int f_needstat; /* if need to stat files */
+int f_newline; /* if precede with newline */
+int f_nonprint; /* show unprintables as ? */
+int f_nosort; /* don't sort output */
+int f_recursive; /* ls subdirectories also */
+int f_reversesort; /* reverse whatever sort is used */
+int f_singlecol; /* use single column output */
+int f_size; /* list size in short listing */
+int f_statustime; /* use time of last mode change */
+int f_dirname; /* if precede with directory name */
+int f_timesort; /* sort by time vice name */
+int f_total; /* if precede with "total" line */
+int f_type; /* add type character for non-regular files */