home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * MAILQ.C
- *
- * (c) Copyright 1990 Kriton Kyrimis
- * uunet.uu.net!theseas.ntua.gr!kriton!kyrimis
- *
- * Hierarchical Spool Conversion 1 Dec 93,
- * Mike J.Bruins bruins@hal9000.apana.org.au
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <libraries/dos.h>
- #include "config.h"
- #include "version.h"
- #ifdef LATTICE
- #include <proto/dos.h>
- #include <proto/exec.h>
- #endif
-
- IDENT(".03");
-
- main(int argc,char **argv){
- /* find the system directories in the spool */
-
- BPTR lk;
- struct FileInfoBlock *fb = 0;
- char path[256], datadir[256];
- int i;
- void ReadSystemD(char *path,char *sys);
-
- if (argc<1) /* Workbench */
- exit(0);
- if (argc==1){
- fb = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock), 0);
- if (!fb) {
- fprintf(stderr, "Can't allocate memory for file info block\n");
- exit(1);
- }
- strcpy(path,GetConfigDir(UUSPOOL));
- lk = Lock(path, ACCESS_READ);
-
- if (!lk) {
- fprintf(stderr, "Can't lock %s\n", path);
- FreeMem(fb, sizeof(struct FileInfoBlock));
- exit(1);
- }
-
- if (!Examine(lk, fb)) {
- fprintf(stderr, "Can't examine %s\n", path);
- FreeMem(fb, sizeof(struct FileInfoBlock));
- UnLock(lk);
- exit(1);
- }
-
- while (ExNext(lk, fb)) { /* step through directory */
- if (fb->fib_DirEntryType > 0) { /* is a directory */
- if(is_in_L_sys_file(fb->fib_FileName)){
- sprintf(datadir,"%s%s",path, fb->fib_FileName);
- ReadSystemD(datadir, fb->fib_FileName);
- }
- }
- }
-
- FreeMem(fb, sizeof(struct FileInfoBlock));
- UnLock(lk);
- }else{
- strcpy(path,GetConfigDir(UUSPOOL));
- for(i=0;i<argc;i++)
- if(is_in_L_sys_file(argv[i])){
- sprintf(datadir,"%s%s",path, argv[i]);
- ReadSystemD(datadir, argv[i]);
- }
- }
- exit(0);
- }
-
- void ReadSystemD(char *path, char *sys){
- /* read a data directory of a system and feed to whereto() */
- BPTR lk;
- char datadir[256];
- struct FileInfoBlock *fb = 0;
- void whereto(char *sys, char *file);
-
- fb = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock), 0);
- if (!fb) {
- fprintf(stderr, "Can't allocate memory for file info block\n");
- return;
- }
- lk = Lock(path, ACCESS_READ);
- if (!lk) {
- fprintf(stderr, "Can't lock %s\n", path);
- FreeMem(fb, sizeof(struct FileInfoBlock));
- return;
- }
- if (!Examine(lk, fb)) {
- fprintf(stderr, "Can't examine %s\n", path);
- FreeMem(fb, sizeof(struct FileInfoBlock));
- UnLock(lk);
- return;
- }
-
- while (ExNext(lk, fb)) { /* step through directory */
- if (fb->fib_DirEntryType < 0) { /* not a directory */
- sprintf(datadir,"%s/%s",path,fb->fib_FileName);
- whereto(datadir, sys);
- }
- }
-
- FreeMem(fb, sizeof(struct FileInfoBlock));
- UnLock(lk);
- }
-
- void whereto(char *path, char *sys){
- /* print the system name and where the mail is going to */
- char tmp[132];
- FILE *f;
-
- 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)) {
- printf("%s %s!%s", path, sys, &tmp[8]);
- break;
- }
- }
- fclose(f);
- return;
- }
-