home *** CD-ROM | disk | FTP | other *** search
- /*
- * MAILQ.C
- *
- * (c) Copyright 1990 Kriton Kyrimis
- *
- * uunet.uu.net!theseas.ntua.gr!kriton!kyrimis
- */
-
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "config.h"
- #include "version.h"
-
- #undef NULL
- #define NULL 0
-
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
-
- #include <pragmas/dos_pragmas.h>
- #include <pragmas/exec_pragmas.h>
-
- IDENT (".05");
-
- BPTR
- lk = NULL;
- struct FileInfoBlock
- *fb = NULL;
-
- void whereto (char *, const int);
-
- void
- cleanup (void)
- {
- if (lk) {
- UnLock (lk);
- lk = NULL;
- }
- if (fb) {
- FreeMem (fb, sizeof (struct FileInfoBlock));
- fb = NULL;
- }
-
- return;
- }
-
- int
- main (int ac, char **av)
- {
- int
- end;
-
-
- atexit (cleanup);
-
- fb = (struct FileInfoBlock *) AllocMem (sizeof (struct FileInfoBlock), MEMF_ANY);
- if (!fb) {
- fprintf (stderr, "Can't allocate memory for file info block\n");
- exit (20);
- }
-
- lk = Lock ((UBYTE *) GetConfigDir (UUSPOOL), ACCESS_READ);
- if (!lk) {
- fprintf (stderr, "Can't lock %s\n", GetConfigDir (UUSPOOL));
- exit (20);
- }
-
- if (!Examine (lk, fb)) {
- fprintf (stderr, "Can't examine %s\n", GetConfigDir (UUSPOOL));
- exit (20);
- }
-
- #define fname fb->fib_FileName
-
- while (ExNext (lk, fb)) {
- if (CheckSignal (SIGBREAKF_CTRL_C))
- break;
-
- if (fb->fib_DirEntryType < 0) {
- if ((fname [0] != 'D') || (fname [1] != '.')) {
- continue;
- }
-
- end = strlen (fname) - 5;
- if (fname [end] != 'X') {
- continue;
- }
-
- whereto (fname, end);
- }
- }
-
- #undef fname
-
- exit (0);
- }
-
- void
- whereto (char *fname, const int end)
- {
- char
- *path,
- tmp [132];
- FILE
- *f;
-
- path = MakeConfigPath (UUSPOOL, fname);
- f = fopen (path, "r");
- if (!f) {
- fprintf (stderr, "Can't open %s\n", tmp);
- return;
- }
-
- while (fgets (tmp, sizeof (tmp), f)) {
- if (strncmp (tmp, "C rmail ", 8) == NULL) {
- fname [end] = '\0';
- printf ("%s %s!%s", path, &fname [2], &tmp [8]);
- break;
- }
- }
- fclose (f);
-
- return;
- }
-