#!/usr/local/bin/icmake -qi

#define VER             "1.00"

void main (int argc, list argv)
{
    string
        voldir;
    list
        dirlist,
	excludelist;
    int
        size,
	i;
	
    if (argc != 2)
    {
        printf ("\n"
	        "ICCE Backup Volume Lister  V" VER "\n"
	        "Copyright (c) ICCE 1994. All rights reserved.\n"
		"\n"
		"listvolumes by Karel Kubat.\n"
		"\n"
		"Usage: listvolumes volumedir\n"
		"where:\n"
		"        volumedir : directory of afio-configuration "
		                                        "definitions\n"
                "\n");
        exit (1);
    }
    
    voldir = element (1, argv);
    chdir (voldir);
    
    if (! (dirlist = makelist ("*.startdir")) )
    {
        printf ("The files in directory ", voldir, "don't seem to have\n"
	        "*.startdir files!\n");
	exit (1);
    }
    if (! (excludelist = makelist ("*.exclude")) )
    {
        printf ("The files in directory ", voldir, "don't seem to have\n"
	        "*.exclude files!\n");
	exit (1);
    }
    
    size = sizeof (dirlist);
    if (size != sizeof (excludelist))
    {
        printf ("The files in directory ", voldir, "don't seem to match.\n"
	        "The *.exclude don't match the *.stardir files!\n");
	exit (1);
    }

    printf ("The following backup volumes are defined:\n");
    for (i = 0; i < size; i++)
        printf (change_ext (element (i, dirlist), ""), " ");
    printf ("\n");
    
    exit (0);
}
