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

#define VER             "1.00"

string 
    sizeflag;
    
void getsizeflag (string av0)
{
    string
        inf;
    list
        input;
	
    inf = change_base (av0, "size");
    inf = change_ext  (inf, "");
    
    if (input = fgets (inf, 0))
        sizeflag = "-s " + element (0, strtok (element (0, input), " \t\n"));
}

void main (int argc, list argv)
{
    string
	backupfile,
    	pattern;
	
    echo (0);
    
    if (argc < 2 || argc > 3)
    {
        printf ("\n"
	        "ICCE Backup Contents Lister  V" VER "\n"
		"Copyright (c) ICCE 1994. All rights reserved.\n"
		"\n"
		"listbackup by Karel Kubat.\n"
		"\n"
		"Usage: listbackup backupfile [pattern]\n"
		"where:\n"
                "       backupfile : the afio'd backup\n"
                "       pattern    : (optional) expression which the files "
		                                        "to list must\n"
                "                    match\n"
		"\n"
                "The contents of the backup are listed. Note that the "
		                                        "files may appear as\n"
                "compressed (.z extension); but would be restored (see "
		                                        "the program\n"
                "restorebackup) as normal files.\n"
		"\n");
        exit (1);
    }

    getsizeflag (element (0, argv));
	
    backupfile = element (1, argv);
    if (argc == 3)
        pattern = element (2, argv);
	
    if (pattern)
        exec ("afio", "-t", sizeflag, "-v", "-y", 
	        "'" + pattern + "'", backupfile);
    else    
        exec ("afio", "-t", sizeflag, "-v", backupfile);
    
    exit (0);
}

    
    