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

#define VER             "1.00"

string 
    home;

void gethome (list envp)
{
    int
        i;
    for (i = 0; i < sizeof (envp); i += 2)
        if (element (i, envp) == "BACKUP_HOME")
	{
	    home = element (i + 1, envp);
	    return;
	}
	
    printf ("listbackups: Environment variable BACKUP_HOME undefined!\n"
            "Either define that variable or use the backup script.\n");
    exit (1);	    
}

void main (int argc, list argv, list envp)
{
    echo (0);

    if (argc != 1)
    {
        printf ("\n"
	        "ICCE Completed Backups Lister  V", VER, "\n"
	        "Copyright (c) ICCE 1994. All rights reserved.\n"
		"\n"
		"listbackups by Karel Kubat.\n"
		"\n"
		"Usage: listbackups\n"
		"The completed backups and possible incrementals are "
		                                "summarized.\n"
                "\n");
        exit (1);
    }
    
    gethome (envp);
    
    exec (home + "/misc/listvolumes", home + "/volumes");
    printf ("\n");
    exec (home + "/misc/liststamps", home + "/stamps");
    
    exit (0);
}
