Debian Codegraph @

swig/disc.swg

raw
1 /* -*- c -*-
2 Copyright (C) 2006, 2008, 2011, 2012 Rocky Bernstein <[email protected]>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* See <cdio/device.h> for more extensive documentation. */
18
19 %constant long int DISC_MODE_CD_DA = CDIO_DISC_MODE_CD_DA;
20 %constant long int DISC_MODE_CD_DATA = CDIO_DISC_MODE_CD_DATA;
21 %constant long int DISC_MODE_CD_XA = CDIO_DISC_MODE_CD_XA;
22 %constant long int DISC_MODE_CD_MIXED = CDIO_DISC_MODE_CD_MIXED;
23 %constant long int DISC_MODE_DVD_ROM = CDIO_DISC_MODE_DVD_ROM;
24 %constant long int DISC_MODE_DVD_RAM = CDIO_DISC_MODE_DVD_RAM;
25 %constant long int DISC_MODE_DVD_R = CDIO_DISC_MODE_DVD_R;
26 %constant long int DISC_MODE_DVD_RW = CDIO_DISC_MODE_DVD_RW;
27 %constant long int DISC_MODE_DVD_PR = CDIO_DISC_MODE_DVD_PR;
28 %constant long int DISC_MODE_DVD_PRW = CDIO_DISC_MODE_DVD_PRW;
29 %constant long int DISC_MODE_DVD_OTHER = CDIO_DISC_MODE_DVD_OTHER;
30 %constant long int DISC_MODE_NO_INFO = CDIO_DISC_MODE_NO_INFO;
31 %constant long int DISC_MODE_ERROR = CDIO_DISC_MODE_ERROR;
32 %constant long int DISC_MODE_CD_I = CDIO_DISC_MODE_CD_I;
33
34 %rename cdio_get_disc_last_lsn get_disc_last_lsn;
35 %feature("autodoc",
36 "get_disc_last_lsn(cdio)->lsn
37 Get the LSN of the end of the CD.
38
39 perlcdio.INVALID_LSN is returned on error.");
40 lsn_t cdio_get_disc_last_lsn(const CdIo_t *p_cdio);
41
42
43 %feature("autodoc",
44 "get_disc_mode(p_cdio) -> str
45
46 Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
47 that we've got. The notion of 'CD' is extended a little to include
48 DVD's.");
49 const char *get_disc_mode (CdIo_t *p_cdio);
50
51 %rename cdio_get_joliet_level get_joliet_level;
52 %feature("autodoc",
53 "get_joliet_level(cdio)->int
54
55 Return the Joliet level recognized for cdio.
56 This only makes sense for something that has an ISO-9660
57 filesystem.");
58 int cdio_get_joliet_level(const CdIo_t *p_cdio);
59
60 /*!
61 Get the media catalog number (MCN) from the CD.
62
63 @return the media catalog number or NULL if there is none or we
64 don't have the ability to get it.
65
66 Note: string is malloc'd so caller has to free() the returned
67 string when done with it.
68
69 */
70 %rename cdio_get_mcn get_mcn;
71 %newobject cdio_get_mcn; // free malloc'd return value
72 char * cdio_get_mcn (const CdIo_t *p_cdio);
73
74 %rename cdio_get_num_tracks get_num_tracks;
75 %feature("autodoc",
76 "get_num_tracks(p_cdio)->int
77
78 Return the number of tracks on the CD.
79 On error $perlcdio::INVALID_TRACK is returned.");
80 track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
81
82 /*========================INLINE======================================*/
83
84 %inline %{
85 const char *
86 get_disc_mode (CdIo_t *p_cdio)
87 {
88 discmode_t discmode = cdio_get_discmode(p_cdio);
89 if (CDIO_DISC_MODE_ERROR == discmode)
90 return (const char *)newSV(0);
91 return discmode2str[discmode];
92 }
93 %}
94
95 /* SV * get_cdtext (CdIo_t *p_cdio); */
96 /* %inline %{ */
97 /* SV * get_cdtext (CdIo_t *p_cdio) */
98 /* { */
99 /* HV * cdtext_hash; */
100 /* cdtext_t *cdtext; const char *str; int num; unsigned int l=0; */
101 /* cdtext = cdio_get_cdtext (p_cdio); */
102 /* if(!cdtext) */
103 /* return newSV(0); //we return undef if there is no cdtext on the disk */
104 /* cdtext_hash = newHV(); */
105 /* for (num=0; num<MAX_CDTEXT_FIELDS; num++) { */
106 /* if(cdtext_get_const(cdtext,num,track)) { */
107 /* l++; */
108 /* str = cdtext_field2str(num); */
109 /* hv_store(cdtext_hash, str, strlen(str), */
110 /* newSVpv(cdtext_get_const(cdtext,num, track), 0), 0); */
111 /* } */
112 /* } */
113 /* if(!l) { */
114 /* SvREFCNT_dec((SV*)cdtext_hash); */
115 /* return newSV(0); */
116 /* } // we could easily return the number of strings, too. */
117 /* return newRV_noinc(sv_2mortal((SV*)cdtext_hash)); */
118 /* } */
119 /* %} */
120
121 uint32_t get_cddb_discid(CdIo_t *p_cdio);
122 %inline %{
123 static int
124 cddb_dec_digit_sum(int n)
125 {
126 int ret=0;
127
128 for (;;) {
129 ret += n%10;
130 n = n/10;
131 if (!n) return ret;
132 }
133 }
134
135 uint32_t get_cddb_discid(CdIo_t *p_cdio)
136 {
137 int i,t,n=0;
138 msf_t start_msf;
139 msf_t msf;
140 track_t i_tracks = cdio_get_num_tracks (p_cdio);
141 if(i_tracks == CDIO_INVALID_TRACK)
142 return 0;
143
144 for (i = 1; i <= i_tracks; i++) {
145 cdio_get_track_msf(p_cdio, i, &msf);
146 n += cddb_dec_digit_sum(cdio_audio_get_msf_seconds(&msf));
147 }
148
149 cdio_get_track_msf(p_cdio, 1, &start_msf);
150 cdio_get_track_msf(p_cdio, CDIO_CDROM_LEADOUT_TRACK, &msf);
151
152 t = cdio_audio_get_msf_seconds(&msf)-cdio_audio_get_msf_seconds(&start_msf);
153
154 return ((n % 0xff) << 24 | t << 8 | i_tracks);
155 }
156 %}
157
158 SV * guess_cd_type(const CdIo_t *cdio, int start_session, track_t track_num);
159 %inline %{
160 SV * guess_cd_type(const CdIo_t *cdio, int start_session, track_t track_num) {
161 cdio_iso_analysis_t t;
162 int r;
163 HV * iso_analysis;
164 r = cdio_guess_cd_type (cdio, start_session, track_num, &t);
165 iso_analysis = newHV();
166 hv_store(iso_analysis, "cdio_fs_t",9, newSViv(r&CDIO_FS_MASK),0);
167 hv_store(iso_analysis, "cdio_fs_cap_t",13, newSViv(r&~CDIO_FS_MASK),0);
168 hv_store(iso_analysis, "joliet_level",12, newSVuv(t.joliet_level),0);
169 hv_store(iso_analysis, "iso_label",9,newSVpv(t.iso_label,0),0);
170 hv_store(iso_analysis, "isofs_size",10, newSVuv(t.isofs_size),0);
171 hv_store(iso_analysis, "UDFVerMinor",11,
172 newSVuv((unsigned int)t.UDFVerMinor),0);
173 hv_store(iso_analysis, "UDFVerMajor",11,
174 newSVuv((unsigned int)t.UDFVerMajor),0);
175
176 return newRV_noinc(sv_2mortal((SV*)iso_analysis));
177 }
178 %}