/* * EX05CON.C * * C/DOS Example program for ArchiveLib 2.0 * * Copyright (c) Greenleaf Software, Inc. 1994 - 1996 * All Rights Reserved * * MEMBERS/FUNCTIONS DEMONSTRATED * * ALArchiveGetComment() * ALEntryGetComment() * ALEntryGetCompressedSize() * ALEntryGetMark() * * DESCRIPTION * * This example program gives a brief listing of an archive's contents. * If you don't specify an archive name on the command line, by * default it will display the contents of dos00.gal. If you don't have a * copy of dos00.gal already, you can create one using EX00CON. * * REVISION HISTORY * * February 1, 1996 2.0A : Second release * */ #include #include #include #include "arclib.h" #include "glarc.h" #include "pkarc.h" int dump( hALEntryList list ); int main( int argc, char *argv[] ) { hALArchive archive; hALEntryList list; char *comment; printf( "Archive Library 2.0\nEX05CON.C\n\n" ); printf( "This example program gives a brief listing of an archive's contents.\n" ); printf( "If you don't specify an archive name on the command line, by\n" ); printf( "default it will display the contents of dos00.gal. If you don't have a\n" ); printf( "copy of dos00.gal already, you can create one using EX00CON.\n" ); getch(); if ( argc == 2 ) #if defined( ZIP ) archive = newALPkArchive( argv[ 1 ] ); else archive = newALPkArchive( "dos00.zip" ); #else archive = newALGlArchive( argv[ 1 ] ); else archive = newALGlArchive( "dos00.gal" ); #endif list = newALListCopyTools( 0 ); ALArchiveReadDirectory( archive, list ); printf( "\n" ); comment = ALArchiveGetComment( archive ); if ( comment ) printf( "Archive comment: %s\n", comment ); dump( list ); return 1; } int dump( hALEntryList list ) { long total = 0; long tsize = 0; long tcomp = 0; hALEntry entry; entry = ALEntryListGetFirstEntry( list ); if ( entry == 0 ) { printf( "No entries in archive\n" ); return 1; } printf( "============================================================================\n" ); printf( "M Name Size Comp Comment\n" ); printf( "----------------------------------------------------------------------------\n" ); while ( entry != 0 ) { total++; tsize += ALStorageGetSize( ALEntryGetStorage( entry ) ); tcomp += ALEntryGetCompressedSize( entry ); printf( ALEntryGetMark( entry ) ? "*" : " " ); printf( "%24s", ALStorageGetName( ALEntryGetStorage( entry ) ) ); printf( "%12ld", ALStorageGetSize( ALEntryGetStorage( entry ) ) ); printf( "%12ld", ALEntryGetCompressedSize( entry ) ); printf( " %s", ALEntryGetComment( entry ) ); printf( "\n" ); entry = ALEntryGetNextEntry( entry ); } printf( "----------------------------------------------------------------------------\n" ); printf( " Total " ); printf( "%9ld", total ); printf( "%12ld", tsize ); printf( "%12ld\n", tcomp ); return 0; }