+/*
+ * pdirectory: print the directory name, labelling it if title is
+ * nonzero, using lp as the place to start reading in the dir.
+ */
+pdirectory (name, title, lp)
+char *name;
+int title;
+struct lbuf **lp;
+{
+ register struct dchain *dp;
+ register struct lbuf *ap;
+ register char *pname;
+ struct lbuf **app;
+
+ filewidth = 0;
+ curdir = name;
+ if (title)
+ printf("\n%s:\n", name);
+ lastp = lp;
+ readdir(name);
+ if (!Cflg)
+ filewidth = MAXFILEWIDTH;
+ colwidth = fixedwidth + filewidth;
+#ifdef notdef
+ /* Taken out because it appears this is done below in pem. */
+ if (tabflg) {
+ if (colwidth <= 8)
+ colwidth = 8;
+ else
+ if (colwidth <= 16)
+ colwidth = 16;
+ }
+#endif
+ if (fflg==0)
+ qsort(lp,lastp - lp,sizeof *lastp,compar);
+ if (Rflg) for (app=lastp-1; app>=lp; app--) {
+ ap = *app;
+ if (ap->ltype == 'd' && strcmp(ap->ln.lname, ".") &&
+ strcmp(ap->ln.lname, "..")) {
+ dp = (struct dchain *) calloc(1, sizeof(struct dchain));
+ pname = makename (curdir, ap->ln.lname);
+ dp->dc_name = (char *) calloc(1, strlen(pname)+1);
+ strcpy(dp->dc_name, pname);
+ dp -> dc_next = dfirst;
+ dfirst = dp;
+ }
+ }
+ if (lflg || sflg)
+ printf("total %D", tblocks);
+ pem(lp, lastp);
+ newline();
+}
+
+/*
+ * pem: print 'em. Print a list of files (e.g. a directory) bounded
+ * by slp and lp.
+ */