| 1 |
blade |
219 |
/*
|
| 2 |
|
|
* This file has been modified for the cdrkit suite.
|
| 3 |
|
|
*
|
| 4 |
|
|
* The behaviour and appearence of the program code below can differ to a major
|
| 5 |
|
|
* extent from the version distributed by the original author(s).
|
| 6 |
|
|
*
|
| 7 |
|
|
* For details, see Changelog file distributed with the cdrkit package. If you
|
| 8 |
|
|
* received this file from another source then ask the distributing person for
|
| 9 |
|
|
* a log of modifications.
|
| 10 |
|
|
*
|
| 11 |
|
|
*/
|
| 12 |
|
|
|
| 13 |
blade |
2 |
/* @(#)auinfo.c 1.23 04/03/01 Copyright 1998-2004 J. Schilling */
|
| 14 |
|
|
#ifndef lint
|
| 15 |
|
|
static char sccsid[] =
|
| 16 |
|
|
"@(#)auinfo.c 1.23 04/03/01 Copyright 1998-2004 J. Schilling";
|
| 17 |
|
|
#endif
|
| 18 |
|
|
/*
|
| 19 |
|
|
* Copyright (c) 1998-2004 J. Schilling
|
| 20 |
|
|
*/
|
| 21 |
|
|
/*
|
| 22 |
|
|
* This program is free software; you can redistribute it and/or modify
|
| 23 |
|
|
* it under the terms of the GNU General Public License version 2
|
| 24 |
|
|
* as published by the Free Software Foundation.
|
| 25 |
|
|
*
|
| 26 |
|
|
* This program is distributed in the hope that it will be useful,
|
| 27 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 28 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 29 |
|
|
* GNU General Public License for more details.
|
| 30 |
|
|
*
|
| 31 |
|
|
* You should have received a copy of the GNU General Public License along with
|
| 32 |
|
|
* this program; see the file COPYING. If not, write to the Free Software
|
| 33 |
|
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 34 |
|
|
*/
|
| 35 |
|
|
|
| 36 |
|
|
#include <mconfig.h>
|
| 37 |
|
|
#include <stdxlib.h>
|
| 38 |
|
|
#include <unixstd.h>
|
| 39 |
|
|
#include <statdefs.h>
|
| 40 |
|
|
#include <stdio.h>
|
| 41 |
|
|
#include <standard.h>
|
| 42 |
|
|
#include <strdefs.h>
|
| 43 |
|
|
#include <deflts.h>
|
| 44 |
|
|
#include <utypes.h>
|
| 45 |
|
|
#include <schily.h>
|
| 46 |
|
|
|
| 47 |
|
|
#include "cdtext.h"
|
| 48 |
|
|
#include "cdrecord.h"
|
| 49 |
|
|
|
| 50 |
|
|
extern int debug;
|
| 51 |
|
|
extern int xdebug;
|
| 52 |
|
|
|
| 53 |
kaner-guest |
368 |
BOOL auinfosize(char *name, track_t *trackp);
|
| 54 |
|
|
void auinfo(char *name, int track, track_t *trackp);
|
| 55 |
|
|
textptr_t *gettextptr(int track, track_t *trackp);
|
| 56 |
|
|
static char *savestr(char *name);
|
| 57 |
|
|
static char *readtag(char *name);
|
| 58 |
|
|
static char *readtstr(char *name);
|
| 59 |
|
|
void setmcn(char *mcn, track_t *trackp);
|
| 60 |
|
|
static void isrc_illchar(char *isrc, int c);
|
| 61 |
|
|
void setisrc(char *isrc, track_t *trackp);
|
| 62 |
|
|
void setindex(char *tindex, track_t *trackp);
|
| 63 |
blade |
2 |
|
| 64 |
|
|
#ifdef XXX
|
| 65 |
kaner-guest |
368 |
int
|
| 66 |
|
|
main(int argc, char *argv[])
|
| 67 |
blade |
2 |
{
|
| 68 |
|
|
/* auinfo("/etc/default/cdrecord");*/
|
| 69 |
|
|
/* auinfo("/mnt2/CD3/audio_01.inf");*/
|
| 70 |
|
|
auinfo("/mnt2/CD3/audio_01.wav");
|
| 71 |
|
|
}
|
| 72 |
|
|
#endif
|
| 73 |
|
|
|
| 74 |
kaner-guest |
368 |
BOOL
|
| 75 |
blade |
248 |
auinfosize(char *name, track_t *trackp)
|
| 76 |
blade |
2 |
{
|
| 77 |
|
|
const char *p;
|
| 78 |
|
|
const char *tlp;
|
| 79 |
|
|
struct stat sb;
|
| 80 |
|
|
long secs;
|
| 81 |
|
|
long nsamples;
|
| 82 |
|
|
Llong tracksize;
|
| 83 |
|
|
|
| 84 |
|
|
if (!is_audio(trackp))
|
| 85 |
|
|
return (FALSE);
|
| 86 |
|
|
|
| 87 |
|
|
if ((trackp->flags & TI_USEINFO) == 0)
|
| 88 |
|
|
return (FALSE);
|
| 89 |
|
|
|
| 90 |
|
|
if ((p = strrchr(name, '.')) == NULL)
|
| 91 |
|
|
return (FALSE);
|
| 92 |
|
|
if (!streql(p, ".inf") && !streql(p, ".INF"))
|
| 93 |
|
|
return (FALSE);
|
| 94 |
|
|
|
| 95 |
|
|
/*
|
| 96 |
|
|
* First check if a bad guy tries to call auinfosize()
|
| 97 |
|
|
* while STDIN_FILENO is a TTY.
|
| 98 |
|
|
*/
|
| 99 |
|
|
if (isatty(STDIN_FILENO)) {
|
| 100 |
|
|
errmsgno(EX_BAD,
|
| 101 |
|
|
"WARNING: Stdin is connected to a terminal.\n");
|
| 102 |
|
|
return (FALSE);
|
| 103 |
|
|
}
|
| 104 |
|
|
|
| 105 |
|
|
if (stat(name, &sb) < 0) /* *.inf file not found */
|
| 106 |
|
|
return (FALSE);
|
| 107 |
|
|
|
| 108 |
|
|
if (sb.st_size > 10000) /* Too large for a *.inf file */
|
| 109 |
|
|
return (FALSE);
|
| 110 |
|
|
|
| 111 |
blade |
316 |
if (cfg_open(name) < 0) /* Cannot open *.inf file */
|
| 112 |
blade |
2 |
return (FALSE);
|
| 113 |
|
|
|
| 114 |
blade |
316 |
tlp = p = readtag("Tracklength");
|
| 115 |
blade |
2 |
if (p == NULL) { /* Tracklength= Tag not found */
|
| 116 |
|
|
errmsgno(EX_BAD,
|
| 117 |
|
|
"WARNING: %s does not contain a 'Tracklength=' tag.\n",
|
| 118 |
|
|
name);
|
| 119 |
blade |
316 |
cfg_close();
|
| 120 |
blade |
2 |
return (FALSE);
|
| 121 |
|
|
}
|
| 122 |
|
|
|
| 123 |
|
|
p = astol(p, &secs);
|
| 124 |
|
|
if (*p != '\0' && *p != ',') {
|
| 125 |
|
|
errmsgno(EX_BAD,
|
| 126 |
|
|
"WARNING: %s: 'Tracklength=' contains illegal parameter '%s'.\n",
|
| 127 |
|
|
name, tlp);
|
| 128 |
blade |
316 |
cfg_close();
|
| 129 |
blade |
2 |
return (FALSE);
|
| 130 |
|
|
}
|
| 131 |
|
|
if (*p == ',')
|
| 132 |
|
|
p++;
|
| 133 |
|
|
p = astol(p, &nsamples);
|
| 134 |
|
|
if (*p != '\0') {
|
| 135 |
|
|
errmsgno(EX_BAD,
|
| 136 |
|
|
"WARNING: %s: 'Tracklength=' contains illegal parameter '%s'.\n",
|
| 137 |
|
|
name, tlp);
|
| 138 |
blade |
316 |
cfg_close();
|
| 139 |
blade |
2 |
return (FALSE);
|
| 140 |
|
|
}
|
| 141 |
|
|
tracksize = (secs * 2352) + (nsamples * 4);
|
| 142 |
|
|
if (xdebug > 0) {
|
| 143 |
blade |
369 |
fprintf(stderr, "%s: Tracksize %lld bytes (%ld sectors, %ld samples)\n",
|
| 144 |
blade |
2 |
name, tracksize, secs, nsamples);
|
| 145 |
|
|
}
|
| 146 |
|
|
trackp->itracksize = tracksize;
|
| 147 |
blade |
316 |
cfg_close();
|
| 148 |
blade |
2 |
return (TRUE);
|
| 149 |
|
|
}
|
| 150 |
|
|
|
| 151 |
kaner-guest |
368 |
void
|
| 152 |
blade |
248 |
auinfo(char *name, int track, track_t *trackp)
|
| 153 |
blade |
2 |
{
|
| 154 |
|
|
char infname[1024];
|
| 155 |
|
|
char *p;
|
| 156 |
|
|
track_t *tp = &trackp[track];
|
| 157 |
|
|
textptr_t *txp;
|
| 158 |
|
|
long l;
|
| 159 |
|
|
long tno = -1;
|
| 160 |
|
|
BOOL isdao = !is_tao(&trackp[0]);
|
| 161 |
|
|
|
| 162 |
|
|
strncpy(infname, name, sizeof (infname)-1);
|
| 163 |
|
|
infname[sizeof (infname)-1] = '\0';
|
| 164 |
|
|
p = strrchr(infname, '.');
|
| 165 |
|
|
if (p != 0 && &p[4] < &name[sizeof (infname)]) {
|
| 166 |
|
|
strcpy(&p[1], "inf");
|
| 167 |
|
|
}
|
| 168 |
|
|
|
| 169 |
blade |
316 |
if (cfg_open(infname) == 0) {
|
| 170 |
blade |
2 |
|
| 171 |
blade |
316 |
p = readtstr("CDINDEX_DISCID");
|
| 172 |
|
|
p = readtag("CDDB_DISKID");
|
| 173 |
blade |
2 |
|
| 174 |
blade |
316 |
p = readtag("MCN");
|
| 175 |
blade |
2 |
if (p && *p) {
|
| 176 |
|
|
setmcn(p, &trackp[0]);
|
| 177 |
|
|
txp = gettextptr(0, trackp); /* MCN is isrc for trk 0*/
|
| 178 |
|
|
txp->tc_isrc = savestr(p);
|
| 179 |
|
|
}
|
| 180 |
|
|
|
| 181 |
blade |
316 |
p = readtag("ISRC");
|
| 182 |
blade |
2 |
if (p && *p) {
|
| 183 |
|
|
setisrc(p, &trackp[track]);
|
| 184 |
|
|
txp = gettextptr(track, trackp);
|
| 185 |
|
|
txp->tc_isrc = savestr(p);
|
| 186 |
|
|
}
|
| 187 |
|
|
|
| 188 |
blade |
316 |
p = readtstr("Albumperformer");
|
| 189 |
blade |
2 |
if (p && *p) {
|
| 190 |
|
|
txp = gettextptr(0, trackp); /* Album perf. in trk 0*/
|
| 191 |
|
|
txp->tc_performer = savestr(p);
|
| 192 |
|
|
}
|
| 193 |
blade |
316 |
p = readtstr("Performer");
|
| 194 |
blade |
2 |
if (p && *p) {
|
| 195 |
|
|
txp = gettextptr(track, trackp);
|
| 196 |
|
|
txp->tc_performer = savestr(p);
|
| 197 |
|
|
}
|
| 198 |
blade |
316 |
p = readtstr("Albumtitle");
|
| 199 |
blade |
2 |
if (p && *p) {
|
| 200 |
|
|
txp = gettextptr(0, trackp); /* Album title in trk 0*/
|
| 201 |
|
|
txp->tc_title = savestr(p);
|
| 202 |
|
|
}
|
| 203 |
blade |
316 |
p = readtstr("Tracktitle");
|
| 204 |
blade |
2 |
if (p && *p) {
|
| 205 |
|
|
txp = gettextptr(track, trackp);
|
| 206 |
|
|
txp->tc_title = savestr(p);
|
| 207 |
|
|
}
|
| 208 |
blade |
316 |
p = readtstr("Songwriter");
|
| 209 |
blade |
2 |
if (p && *p) {
|
| 210 |
|
|
txp = gettextptr(track, trackp);
|
| 211 |
|
|
txp->tc_songwriter = savestr(p);
|
| 212 |
|
|
}
|
| 213 |
blade |
316 |
p = readtstr("Composer");
|
| 214 |
blade |
2 |
if (p && *p) {
|
| 215 |
|
|
txp = gettextptr(track, trackp);
|
| 216 |
|
|
txp->tc_composer = savestr(p);
|
| 217 |
|
|
}
|
| 218 |
blade |
316 |
p = readtstr("Arranger");
|
| 219 |
blade |
2 |
if (p && *p) {
|
| 220 |
|
|
txp = gettextptr(track, trackp);
|
| 221 |
|
|
txp->tc_arranger = savestr(p);
|
| 222 |
|
|
}
|
| 223 |
blade |
316 |
p = readtstr("Message");
|
| 224 |
blade |
2 |
if (p && *p) {
|
| 225 |
|
|
txp = gettextptr(track, trackp);
|
| 226 |
|
|
txp->tc_message = savestr(p);
|
| 227 |
|
|
}
|
| 228 |
blade |
316 |
p = readtstr("Diskid");
|
| 229 |
blade |
2 |
if (p && *p) {
|
| 230 |
|
|
txp = gettextptr(0, trackp); /* Disk id is in trk 0*/
|
| 231 |
|
|
txp->tc_title = savestr(p);
|
| 232 |
|
|
}
|
| 233 |
blade |
316 |
p = readtstr("Closed_info");
|
| 234 |
blade |
2 |
if (p && *p) {
|
| 235 |
|
|
txp = gettextptr(track, trackp);
|
| 236 |
|
|
txp->tc_closed_info = savestr(p);
|
| 237 |
|
|
}
|
| 238 |
|
|
|
| 239 |
blade |
316 |
p = readtag("Tracknumber");
|
| 240 |
blade |
2 |
if (p && isdao)
|
| 241 |
|
|
astol(p, &tno);
|
| 242 |
|
|
|
| 243 |
blade |
316 |
p = readtag("Trackstart");
|
| 244 |
blade |
2 |
if (p && isdao) {
|
| 245 |
|
|
l = -1L;
|
| 246 |
|
|
astol(p, &l);
|
| 247 |
|
|
if (track == 1 && tno == 1 && l > 0) {
|
| 248 |
|
|
trackp[1].pregapsize = 150 + l;
|
| 249 |
|
|
printf("Track1 Start: '%s' (%ld)\n", p, l);
|
| 250 |
|
|
}
|
| 251 |
|
|
}
|
| 252 |
|
|
|
| 253 |
blade |
316 |
p = readtag("Tracklength");
|
| 254 |
blade |
2 |
|
| 255 |
blade |
316 |
p = readtag("Pre-emphasis");
|
| 256 |
blade |
2 |
if (p && *p) {
|
| 257 |
|
|
if (strncmp(p, "yes", 3) == 0) {
|
| 258 |
|
|
tp->flags |= TI_PREEMP;
|
| 259 |
|
|
if ((tp->tracktype & TOC_MASK) == TOC_DA)
|
| 260 |
|
|
tp->sectype = SECT_AUDIO_PRE;
|
| 261 |
|
|
|
| 262 |
|
|
} else if (strncmp(p, "no", 2) == 0) {
|
| 263 |
|
|
tp->flags &= ~TI_PREEMP;
|
| 264 |
|
|
if ((tp->tracktype & TOC_MASK) == TOC_DA)
|
| 265 |
|
|
tp->sectype = SECT_AUDIO_NOPRE;
|
| 266 |
|
|
}
|
| 267 |
|
|
}
|
| 268 |
|
|
|
| 269 |
blade |
316 |
p = readtag("Channels");
|
| 270 |
|
|
p = readtag("Copy_permitted");
|
| 271 |
blade |
2 |
if (p && *p) {
|
| 272 |
|
|
/*
|
| 273 |
|
|
* -useinfo always wins
|
| 274 |
|
|
*/
|
| 275 |
|
|
tp->flags &= ~(TI_COPY|TI_SCMS);
|
| 276 |
|
|
|
| 277 |
|
|
if (strncmp(p, "yes", 3) == 0)
|
| 278 |
|
|
tp->flags |= TI_COPY;
|
| 279 |
|
|
else if (strncmp(p, "no", 2) == 0)
|
| 280 |
|
|
tp->flags |= TI_SCMS;
|
| 281 |
|
|
else if (strncmp(p, "once", 2) == 0)
|
| 282 |
|
|
tp->flags &= ~(TI_COPY|TI_SCMS);
|
| 283 |
|
|
}
|
| 284 |
blade |
316 |
p = readtag("Endianess");
|
| 285 |
|
|
p = readtag("Index");
|
| 286 |
blade |
2 |
if (p && *p && isdao)
|
| 287 |
|
|
setindex(p, &trackp[track]);
|
| 288 |
|
|
|
| 289 |
blade |
316 |
p = readtag("Index0");
|
| 290 |
blade |
2 |
if (p && isdao) {
|
| 291 |
|
|
Llong ts;
|
| 292 |
|
|
Llong ps;
|
| 293 |
|
|
|
| 294 |
|
|
l = -2L;
|
| 295 |
|
|
astol(p, &l);
|
| 296 |
|
|
if (l == -1) {
|
| 297 |
|
|
trackp[track+1].pregapsize = 0;
|
| 298 |
|
|
} else if (l > 0) {
|
| 299 |
|
|
ts = tp->itracksize / tp->isecsize;
|
| 300 |
|
|
ps = ts - l;
|
| 301 |
|
|
if (ps > 0)
|
| 302 |
|
|
trackp[track+1].pregapsize = ps;
|
| 303 |
|
|
}
|
| 304 |
|
|
}
|
| 305 |
|
|
}
|
| 306 |
|
|
|
| 307 |
|
|
}
|
| 308 |
|
|
|
| 309 |
blade |
248 |
textptr_t *
|
| 310 |
|
|
gettextptr(int track, track_t *trackp)
|
| 311 |
blade |
2 |
{
|
| 312 |
|
|
register textptr_t *txp;
|
| 313 |
|
|
|
| 314 |
|
|
txp = (textptr_t *)trackp[track].text;
|
| 315 |
|
|
if (txp == NULL) {
|
| 316 |
|
|
txp = malloc(sizeof (textptr_t));
|
| 317 |
|
|
if (txp == NULL)
|
| 318 |
|
|
comerr("Cannot malloc CD-Text structure.\n");
|
| 319 |
|
|
fillbytes(txp, sizeof (textptr_t), '\0');
|
| 320 |
|
|
trackp[track].text = txp;
|
| 321 |
|
|
}
|
| 322 |
|
|
return (txp);
|
| 323 |
|
|
}
|
| 324 |
|
|
|
| 325 |
blade |
248 |
static char *
|
| 326 |
|
|
savestr(char *str)
|
| 327 |
blade |
2 |
{
|
| 328 |
|
|
char *ret;
|
| 329 |
|
|
|
| 330 |
|
|
ret = malloc(strlen(str)+1);
|
| 331 |
|
|
if (ret)
|
| 332 |
|
|
strcpy(ret, str);
|
| 333 |
|
|
else
|
| 334 |
|
|
comerr("Cannot malloc auinfo string.\n");
|
| 335 |
|
|
return (ret);
|
| 336 |
|
|
}
|
| 337 |
|
|
|
| 338 |
blade |
248 |
static char *
|
| 339 |
|
|
readtag(char *name)
|
| 340 |
blade |
2 |
{
|
| 341 |
|
|
register char *p;
|
| 342 |
|
|
|
| 343 |
blade |
316 |
p = cfg_get(name);
|
| 344 |
|
|
if (debug)
|
| 345 |
|
|
printf("%s '%s'\n", name, p);
|
| 346 |
|
|
return (p);
|
| 347 |
blade |
2 |
}
|
| 348 |
|
|
|
| 349 |
blade |
248 |
static char *
|
| 350 |
|
|
readtstr(char *name)
|
| 351 |
blade |
2 |
{
|
| 352 |
|
|
register char *p;
|
| 353 |
|
|
register char *p2;
|
| 354 |
|
|
|
| 355 |
|
|
p = readtag(name);
|
| 356 |
|
|
if (p && *p == '\'') {
|
| 357 |
|
|
p2 = ++p;
|
| 358 |
|
|
while (*p2 != '\0')
|
| 359 |
|
|
p2++;
|
| 360 |
|
|
while (p2 > p && *p2 != '\'')
|
| 361 |
|
|
p2--;
|
| 362 |
|
|
*p2 = '\0';
|
| 363 |
|
|
if (debug)
|
| 364 |
|
|
printf("%s '%s'\n", name, p);
|
| 365 |
|
|
}
|
| 366 |
|
|
return (p);
|
| 367 |
|
|
}
|
| 368 |
|
|
|
| 369 |
|
|
/*
|
| 370 |
|
|
* Media catalog number is a 13 digit number.
|
| 371 |
|
|
*/
|
| 372 |
kaner-guest |
368 |
void
|
| 373 |
blade |
248 |
setmcn(char *mcn, track_t *trackp)
|
| 374 |
blade |
2 |
{
|
| 375 |
|
|
register char *p;
|
| 376 |
|
|
|
| 377 |
|
|
if (strlen(mcn) != 13)
|
| 378 |
|
|
comerrno(EX_BAD, "MCN '%s' has illegal length.\n", mcn);
|
| 379 |
|
|
|
| 380 |
|
|
for (p = mcn; *p; p++) {
|
| 381 |
|
|
if (*p < '0' || *p > '9')
|
| 382 |
|
|
comerrno(EX_BAD, "MCN '%s' contains illegal character '%c'.\n", mcn, *p);
|
| 383 |
|
|
}
|
| 384 |
|
|
p = malloc(14);
|
| 385 |
|
|
strcpy(p, mcn);
|
| 386 |
|
|
trackp->isrc = p;
|
| 387 |
|
|
|
| 388 |
|
|
if (debug)
|
| 389 |
|
|
printf("Track %d MCN: '%s'\n", (int)trackp->trackno, trackp->isrc);
|
| 390 |
|
|
}
|
| 391 |
|
|
|
| 392 |
blade |
248 |
static char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
| 393 |
blade |
2 |
|
| 394 |
kaner-guest |
368 |
static void
|
| 395 |
blade |
248 |
isrc_illchar(char *isrc, int c)
|
| 396 |
blade |
2 |
{
|
| 397 |
|
|
errmsgno(EX_BAD, "ISRC '%s' contains illegal character '%c'.\n", isrc, c);
|
| 398 |
|
|
}
|
| 399 |
|
|
|
| 400 |
|
|
/*
|
| 401 |
|
|
* ISRC is 12 Byte:
|
| 402 |
|
|
*
|
| 403 |
|
|
* Country code 'C' (alpha) 2 Bytes
|
| 404 |
|
|
* Owner code 'O' (alphanumeric) 3 Bytes
|
| 405 |
|
|
* Year of record 'Y' (numeric) 2 Bytes
|
| 406 |
|
|
* Serial number 'S' (numeric) 5 Bytes
|
| 407 |
|
|
*
|
| 408 |
|
|
* CC-OOO-YY-SSSSS
|
| 409 |
|
|
*/
|
| 410 |
kaner-guest |
368 |
void
|
| 411 |
blade |
248 |
setisrc(char *isrc, track_t *trackp)
|
| 412 |
blade |
2 |
{
|
| 413 |
|
|
char ibuf[13];
|
| 414 |
|
|
char *ip;
|
| 415 |
|
|
char *p;
|
| 416 |
|
|
int i;
|
| 417 |
|
|
int len;
|
| 418 |
|
|
|
| 419 |
|
|
if ((len = strlen(isrc)) != 12) {
|
| 420 |
|
|
for (p = isrc, i = 0; *p; p++) {
|
| 421 |
|
|
if (*p == '-')
|
| 422 |
|
|
i++;
|
| 423 |
|
|
}
|
| 424 |
|
|
if (((len - i) != 12) || i > 3)
|
| 425 |
|
|
comerrno(EX_BAD, "ISRC '%s' has illegal length.\n", isrc);
|
| 426 |
|
|
}
|
| 427 |
|
|
|
| 428 |
|
|
/*
|
| 429 |
|
|
* The country code.
|
| 430 |
|
|
*/
|
| 431 |
|
|
for (p = isrc, ip = ibuf, i = 0; i < 2; p++, i++) {
|
| 432 |
|
|
*ip++ = *p;
|
| 433 |
|
|
if (!strchr(upper, *p)) {
|
| 434 |
|
|
/* goto illchar;*/
|
| 435 |
|
|
/*
|
| 436 |
|
|
* Flag numbers but accept them.
|
| 437 |
|
|
*/
|
| 438 |
|
|
isrc_illchar(isrc, *p);
|
| 439 |
|
|
if (*p >= '0' && *p <= '9')
|
| 440 |
|
|
continue;
|
| 441 |
|
|
exit(EX_BAD);
|
| 442 |
|
|
}
|
| 443 |
|
|
}
|
| 444 |
|
|
if (*p == '-')
|
| 445 |
|
|
p++;
|
| 446 |
|
|
|
| 447 |
|
|
/*
|
| 448 |
|
|
* The owner code.
|
| 449 |
|
|
*/
|
| 450 |
|
|
for (i = 0; i < 3; p++, i++) {
|
| 451 |
|
|
*ip++ = *p;
|
| 452 |
|
|
if (strchr(upper, *p))
|
| 453 |
|
|
continue;
|
| 454 |
|
|
if (*p >= '0' && *p <= '9')
|
| 455 |
|
|
continue;
|
| 456 |
|
|
goto illchar;
|
| 457 |
|
|
}
|
| 458 |
|
|
if (*p == '-')
|
| 459 |
|
|
p++;
|
| 460 |
|
|
|
| 461 |
|
|
/*
|
| 462 |
|
|
* The Year and the recording number (2 + 5 numbers).
|
| 463 |
|
|
*/
|
| 464 |
|
|
for (i = 0; i < 7; p++, i++) {
|
| 465 |
|
|
*ip++ = *p;
|
| 466 |
|
|
if (*p >= '0' && *p <= '9')
|
| 467 |
|
|
continue;
|
| 468 |
|
|
if (*p == '-' && i == 2) {
|
| 469 |
|
|
ip--;
|
| 470 |
|
|
i--;
|
| 471 |
|
|
continue;
|
| 472 |
|
|
}
|
| 473 |
|
|
goto illchar;
|
| 474 |
|
|
}
|
| 475 |
|
|
*ip = '\0';
|
| 476 |
|
|
p = malloc(13);
|
| 477 |
|
|
strcpy(p, ibuf);
|
| 478 |
|
|
trackp->isrc = p;
|
| 479 |
|
|
|
| 480 |
|
|
if (debug)
|
| 481 |
|
|
printf("Track %d ISRC: '%s'\n", (int)trackp->trackno, trackp->isrc);
|
| 482 |
|
|
return;
|
| 483 |
|
|
illchar:
|
| 484 |
|
|
isrc_illchar(isrc, *p);
|
| 485 |
|
|
exit(EX_BAD);
|
| 486 |
|
|
}
|
| 487 |
|
|
|
| 488 |
kaner-guest |
368 |
void
|
| 489 |
blade |
248 |
setindex(char *tindex, track_t *trackp)
|
| 490 |
blade |
2 |
{
|
| 491 |
|
|
char *p;
|
| 492 |
|
|
int i;
|
| 493 |
|
|
int nindex;
|
| 494 |
|
|
long idx;
|
| 495 |
|
|
long *idxlist;
|
| 496 |
|
|
|
| 497 |
|
|
idxlist = malloc(100*sizeof (long));
|
| 498 |
|
|
p = tindex;
|
| 499 |
|
|
idxlist[0] = 0;
|
| 500 |
|
|
i = 0;
|
| 501 |
|
|
while (*p) {
|
| 502 |
|
|
p = astol(p, &idx);
|
| 503 |
|
|
if (*p != '\0' && *p != ' ' && *p != '\t' && *p != ',')
|
| 504 |
|
|
goto illchar;
|
| 505 |
|
|
i++;
|
| 506 |
|
|
if (i > 99)
|
| 507 |
|
|
comerrno(EX_BAD, "Too many indices for track %d\n", (int)trackp->trackno);
|
| 508 |
|
|
idxlist[i] = idx;
|
| 509 |
|
|
if (*p == ',')
|
| 510 |
|
|
p++;
|
| 511 |
|
|
while (*p == ' ' || *p == '\t')
|
| 512 |
|
|
p++;
|
| 513 |
|
|
}
|
| 514 |
|
|
nindex = i;
|
| 515 |
|
|
|
| 516 |
|
|
if (debug)
|
| 517 |
|
|
printf("Track %d %d Index: '%s'\n", (int)trackp->trackno, i, tindex);
|
| 518 |
|
|
|
| 519 |
|
|
if (debug) {
|
| 520 |
|
|
for (i = 0; i <= nindex; i++)
|
| 521 |
|
|
printf("%d: %ld\n", i, idxlist[i]);
|
| 522 |
|
|
}
|
| 523 |
|
|
|
| 524 |
|
|
trackp->nindex = nindex;
|
| 525 |
|
|
trackp->tindex = idxlist;
|
| 526 |
|
|
return;
|
| 527 |
|
|
illchar:
|
| 528 |
|
|
comerrno(EX_BAD, "Index '%s' contains illegal character '%c'.\n", tindex, *p);
|
| 529 |
|
|
}
|