diff --git a/example/iso1.c b/example/iso1.c index d77be3a8..2b691c80 100644 --- a/example/iso1.c +++ b/example/iso1.c @@ -1,7 +1,7 @@ /* - $Id: iso1.c,v 1.3 2005/01/12 11:34:51 rocky Exp $ + $Id: iso1.c,v 1.4 2005/02/03 07:32:32 rocky Exp $ - Copyright (C) 2004 Rocky Bernstein + Copyright (C) 2004, 2005 Rocky Bernstein This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,11 +54,19 @@ main(int argc, const char *argv[]) { CdioList_t *entlist; CdioListNode_t *entnode; + char const *psz_fname; + iso9660_t *p_iso; - iso9660_t *p_iso = iso9660_open (ISO9660_IMAGE); + if (argc > 1) + psz_fname = argv[1]; + else + psz_fname = ISO9660_IMAGE; + + p_iso = iso9660_open (psz_fname); if (NULL == p_iso) { - fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", ISO9660_IMAGE); + fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n", + psz_fname); return 1; } @@ -66,16 +74,20 @@ main(int argc, const char *argv[]) /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ - _CDIO_LIST_FOREACH (entnode, entlist) + if (entlist) { + _CDIO_LIST_FOREACH (entnode, entlist) { char filename[4096]; iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (entnode); iso9660_name_translate(p_statbuf->filename, filename); printf ("/%s\n", filename); + free(p_statbuf); } - - _cdio_list_free (entlist, true); + + _cdio_list_free (entlist, true); + } + iso9660_close(p_iso); return 0; diff --git a/example/iso2.c b/example/iso2.c index 6e113208..05dcf361 100644 --- a/example/iso2.c +++ b/example/iso2.c @@ -1,5 +1,5 @@ /* - $Id: iso2.c,v 1.5 2005/01/04 04:40:22 rocky Exp $ + $Id: iso2.c,v 1.6 2005/02/03 07:32:32 rocky Exp $ Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -19,7 +19,7 @@ */ /* Simple program to show using libiso9660 to extract a file from a - cue/bin CD-IMAGE. + cue/bin CD image. */ /* This is the CD-image with an ISO-9660 filesystem */ @@ -73,21 +73,28 @@ main(int argc, const char *argv[]) iso9660_stat_t *p_statbuf; FILE *p_outfd; int i; + char const *psz_fname; + CdIo_t *p_cdio; - CdIo_t *p_cdio = cdio_open (ISO9660_IMAGE, DRIVER_BINCUE); - + if (argc > 1) + psz_fname = argv[1]; + else + psz_fname = ISO9660_IMAGE; + + p_cdio = cdio_open (psz_fname, DRIVER_BINCUE); if (NULL == p_cdio) { - fprintf(stderr, "Sorry, couldn't open BIN/CUE image %s\n", ISO9660_IMAGE); + fprintf(stderr, "Sorry, couldn't open %s as a BIN/CUE image\n", + psz_fname); return 1; } - p_statbuf = iso9660_fs_stat (p_cdio, ISO9660_FILENAME); + p_statbuf = iso9660_fs_stat (p_cdio, psz_fname); if (NULL == p_statbuf) { fprintf(stderr, "Could not get ISO-9660 file information for file %s\n", - ISO9660_FILENAME); + psz_fname); cdio_destroy(p_cdio); return 2; } @@ -134,7 +141,8 @@ main(int argc, const char *argv[]) if (ftruncate (fileno (p_outfd), p_statbuf->size)) perror ("ftruncate()"); - printf("Extraction of file 'copying' from %s successful.\n", ISO9660_IMAGE); + printf("Extraction of file 'copying' from %s successful.\n", + psz_fname); my_exit(0); }