# #include "rqfile.h" #include char *maildir = "/maild"; char *rqext = "req"; main () { int msiz, siz, fd; char filename[NAMSIZ]; struct req_rec recrd; char *ext (); int mfd; struct dir dbuf; chdir (maildir); if ((mfd = open (maildir, 0)) < 0) error ("can't open mail directory\n"); for (msiz = read (mfd, &dbuf, sizeof (dbuf)); msiz > 0; msiz = read (mfd, &dbuf, sizeof (dbuf)) ) if (dbuf.d_ino!=0 && strcmp (ext (dbuf.d_name), rqext) == 0) { if ((fd = open (dbuf.d_name, 0)) < 0) error ("can't open request file\n"); read (fd, filename, NAMSIZ); printf ("%s\n", filename); siz = read (fd, &recrd, sizeof (recrd)); while (siz >= sizeof (recrd)) { printf ("%s %d\n",recrd.rq_name, recrd.rq_retries); siz = read (fd, &recrd, sizeof (recrd)); } printf ("\n"); close (fd); } close (mfd); exit (0); } char *ext (fname) /* This program returns a string containing the "extension" of the * specified filename. The extension is defined as the string of * characters following the last '.' in the filename. * Caution: since this routine runs as the inner loop of the program, * it is coded for efficiency and may be hard to understand. * * Returns: * string containing the extension, or 0 if none * * Arguments: */ register char *fname; /* file name */ { register int extn; for (extn = 0; *fname != 0; ) if (*fname++ == '.') extn = fname; return (extn); } /* * Compare strings: s1>s2: >0 s1==s2: 0 s1