File: info1.c

package info (click to toggle)
vcdimager 0.7.23-4
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 4,232 kB
  • ctags: 1,864
  • sloc: ansic: 18,143; sh: 9,372; xml: 317; makefile: 288
file content (96 lines) | stat: -rw-r--r-- 3,003 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
    $Id: info1.c,v 1.2 2005/04/29 03:42:19 rocky Exp $

    Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>

    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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
/* Simple example of using the libvcdinfo library. */


#include <stdio.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif

#include <libvcd/info.h>
#include <libvcd/logging.h>
#include <cdio/iso9660.h>

int
main (int argc, const char *argv[])
{
  vcdinfo_obj_t *p_vcdinfo;
  char *psz_source = NULL;
  char *psz = NULL;

  /* Set to give only errors on open, not warnings. */
  vcd_loglevel_default = VCD_LOG_ERROR; 

  if ( vcdinfo_open(&p_vcdinfo, &psz_source, DRIVER_DEVICE,
                    NULL) != VCDINFO_OPEN_VCD) {
    printf("Unable to find a CD-ROM with a (S)VCD in it\n");
    return 1;
  }
  vcd_loglevel_default = VCD_LOG_WARN;

  /* Print out some of the VCD info. */
  printf ("VCD type: `%.16s'\n",    vcdinfo_get_format_version_str(p_vcdinfo));
  printf ("Album id: `%.16s'\n",    vcdinfo_get_album_id(p_vcdinfo));
  printf ("Volume id: `%s'\n",      vcdinfo_get_volume_id(p_vcdinfo));
  printf ("Volume Set id: `%s'\n",  vcdinfo_get_volumeset_id(p_vcdinfo));
  printf ("Volume %d of %d\n",      vcdinfo_get_volume_num(p_vcdinfo),
	                            vcdinfo_get_volume_count(p_vcdinfo));

  psz = vcdinfo_get_preparer_id(p_vcdinfo);
  printf ("Preparer id: `%s'\n",    psz);
  free(psz);
  
  psz = vcdinfo_get_publisher_id(p_vcdinfo);
  printf ("Publisher id: `%s'\n",  psz);
  free(psz);

  psz = vcdinfo_get_system_id(p_vcdinfo);
  printf ("System id: `%s'\n",      psz);
  free(psz);

  psz = vcdinfo_get_application_id(p_vcdinfo);
  printf ("Application id: `%s'\n", psz);
  free(psz);
  
  { 
    const iso9660_pvd_t *p_pvd = vcdinfo_get_pvd(p_vcdinfo);

    if (iso9660_get_pvd_type(p_pvd) != ISO_VD_PRIMARY)
      printf ("Unexpected descriptor type\n");
    
    if (strncmp (iso9660_get_pvd_id(p_pvd), ISO_STANDARD_ID, 
		 strlen (ISO_STANDARD_ID)))
      printf ("Unexpected ID encountered (expected `" ISO_STANDARD_ID "'");
  
    printf("PVD ID: `%.5s'\n",  iso9660_get_pvd_id(p_pvd));
    printf("PVD version: %d\n", iso9660_get_pvd_version(p_pvd));
  }

  free(psz_source);
  vcdinfo_close(p_vcdinfo);
  return 0;
}