⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdrecord.c

📁 另一种方法编辑刻录程序的代码!要的与偶联系呀
💻 C
📖 第 1 页 / 共 4 页
字号:
LOCAL intcheckfiles(tracks, trackp)	int	tracks;	track_t	*trackp;{	int	i;	int	isaudio = 1;	for (i = 1; i <= tracks; i++) {		if (!is_audio(&trackp[i]))			isaudio = 0;		checkfile(i, &trackp[i]);	}	return (isaudio);}LOCAL voidsetpregaps(tracks, trackp)	int	tracks;	track_t	*trackp;{	int	i;	int	sectype;	track_t	*tp;	sectype = trackp[1].sectype;	for (i = 1; i <= tracks; i++) {		tp = &trackp[i];		if (tp->pregapsize == -1L) {			tp->pregapsize = 150;		/* Default Pre GAP */			if (sectype != tp->sectype) {				tp->pregapsize = 255;	/* Pre GAP is 255 */			}		}		sectype = tp->sectype;			/* Save old sectype */	}}LOCAL longchecktsize(tracks, trackp)	int	tracks;	track_t	*trackp;{	int	i;	long	curr;	long	total = 0;	Ullong	btotal;	track_t	*tp;	for (i = 1; i <= tracks; i++) {		tp = &trackp[i];		if (tp->tracksize >=0) {			curr = (tp->tracksize + (tp->secsize-1)) / tp->secsize;			curr += (tp->padsize + (tp->secsize-1)) / tp->secsize;			if (curr < 300)		/* Minimum track size is 4s */				curr = 300;			if (!is_audio(tp))				curr += 2;			if (i > 1)				curr += tp->pregapsize;			total += curr;		}	}	if (!lverbose)		return (total);	btotal = (Ullong)total * 2352;/* XXX Sector Size ??? */	if (tracks > 0) {		printf("Total size:     %3lu MB (%02d:%02d.%02d) = %ld sectors\n",			(Ulong)(btotal >> 20),			minutes(btotal),			seconds(btotal),			hseconds(btotal), total);		btotal += 150 * 2352;		printf("Lout start:     %3lu MB (%02d:%02d/%02d) = %ld sectors\n",			(Ulong)(btotal >> 20),			minutes(btotal),			seconds(btotal),			frames(btotal), total);	}	return (total);}LOCAL voidchecksize(trackp)	track_t	*trackp;{	struct stat	st;	/*	 * If the current input file is a regular file and	 * 'padsize=' has not been specified,	 * use fstat() or file parser to get the size of the file.	 */	if (trackp->tracksize < 0 && (trackp->flags & TI_ISOSIZE) != 0) {		trackp->tracksize = isosize(trackp->f);	}	if (trackp->tracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {		trackp->tracksize = ausize(trackp->f);	}	if (trackp->tracksize < 0 && (trackp->flags & TI_NOAUHDR) == 0) {		trackp->tracksize = wavsize(trackp->f);		if (trackp->tracksize > 0)	/* Force little endian input */			trackp->flags |= TI_SWAB;	}	if (trackp->tracksize == AU_BAD_CODING) {		comerrno(EX_BAD, "Inappropriate audio coding in '%s'.\n",							trackp->filename);	}	if (trackp->tracksize < 0 &&			fstat(trackp->f, &st) >= 0 && S_ISREG(st.st_mode)) {		trackp->tracksize = st.st_size;	}}LOCAL BOOLcheckdsize(dp, dsp, tsize)	cdr_t	*dp;	dstat_t	*dsp;	long	tsize;{	long	startsec = 0L;	long	endsec = 0L;	silent++;	(*dp->cdr_next_wr_address)(/*i*/ 0, (track_t *)0, &startsec);	silent--;	endsec = startsec + tsize;	if (dsp->ds_maxblocks > 0) {		if (lverbose)			printf("Blocks total: %ld Blocks current: %ld Blocks remaining: %ld\n",					dsp->ds_maxblocks,					dsp->ds_maxblocks - startsec,					dsp->ds_maxblocks - endsec);		if (endsec > dsp->ds_maxblocks) {			errmsgno(EX_BAD,			"WARNING: Data may not fit on current disk.\n");			/* XXX Check for flags & CDR_NO_LOLIMIT *//*			return (FALSE);*/		}		if (lverbose && dsp->ds_maxrblocks > 0)			printf("RBlocks total: %ld RBlocks current: %ld RBlocks remaining: %ld\n",					dsp->ds_maxrblocks,					dsp->ds_maxrblocks - startsec,					dsp->ds_maxrblocks - endsec);		if (dsp->ds_maxrblocks > 0 && endsec > dsp->ds_maxrblocks) {			errmsgno(EX_BAD,			"Data does not fit on current disk.\n");			return (FALSE);		}	} else {		if (endsec >= (405000-301)) {			/*<90 min disk*/			errmsgno(EX_BAD,				"Data will not fit on any disk.\n");			return (FALSE);		} else if (endsec >= (333000-150)) {		/* 74 min disk*/			errmsgno(EX_BAD,			"WARNING: Data may not fit on standard 74min disk.\n");		}	}	return (TRUE);}LOCAL voidraise_fdlim(){#ifdef	RLIMIT_NOFILE	struct rlimit	rlim;	/*	 * Set max # of file descriptors to be able to hold all files open	 */	getrlimit(RLIMIT_NOFILE, &rlim);	rlim.rlim_cur = MAX_TRACK + 10;	if (rlim.rlim_cur > rlim.rlim_max)		errmsgno(EX_BAD,			"warning: low file descriptor limit (%ld)\n",							rlim.rlim_max);	setrlimit(RLIMIT_NOFILE, &rlim);#endif	/* RLIMIT_NOFILE */}char	*opts ="help,version,checkdrive,prcap,inq,scanbus,reset,ignsize,dev*,timeout#,driver*,tsize&,padsize&,pregap&,defpregap&,speed#,load,eject,dummy,msinfo,toc,multi,fix,nofix,debug,v+,V+,audio,data,mode2,xa1,xa2,cdi,isosize,nopreemp,preemp,nopad,pad,swab,fs&,blank&,pktsize#,packet,noclose";LOCAL voidgargs(ac, av, tracksp, trackp, devp, timeoutp, dpp, speedp, flagsp, toctypep, blankp)	int	ac;	char	**av;	int	*tracksp;	track_t	*trackp;	cdr_t	**dpp;	char	**devp;	int	*timeoutp;	int	*speedp;	long	*flagsp;	int	*toctypep;	int	*blankp;{	int	cac;	char	* const*cav;	char	*driver = NULL;	long	bltype = -1;	Llong	tracksize;	Llong	padsize;	long	pregapsize;	long	defpregap = -1L;	long	secsize;	int	pktsize;	int	speed = -1;	int	help = 0;	int	version = 0;	int	checkdrive = 0;	int	prcap = 0;	int	inq = 0;	int	scanbus = 0;	int	reset = 0;	int	ignsize = 0;	int	load = 0;	int	eject = 0;	int	dummy = 0;	int	msinfo = 0;	int	toc = 0;	int	multi = 0;	int	fix = 0;	int	nofix = 0;	int	audio;	int	data;	int	mode2;	int	xa1;	int	xa2;	int	cdi;	int	isize;	int	ispacket = 0;	int	noclose = 0;	int	preemp = 0;	int	nopreemp;	int	pad = 0;	int	bswab = 0;	int	nopad;	int	flags;	int	tracks = *tracksp;	int	tracktype = TOC_ROM;	int	sectype = ST_ROM_MODE1;	int	dbtype = DB_ROM_MODE1;	cac = --ac;	cav = ++av;	for (;; cac--,cav++) {		tracksize = (Llong)-1L;		padsize = (Llong)0L;		pregapsize = defpregap;		audio = data = mode2 = xa1 = xa2 = cdi = 0;		isize = nopreemp = nopad = 0;		pktsize = 0;		if (getargs(&cac, &cav, opts,				&help, &version, &checkdrive, &prcap,				&inq, &scanbus, &reset, &ignsize,				devp, timeoutp, &driver,				getllnum, &tracksize,				getllnum, &padsize,				getnum, &pregapsize,				getnum, &defpregap,				&speed,				&load, &eject, &dummy, &msinfo, &toc,				&multi, &fix, &nofix,				&debug, &lverbose, &verbose,				&audio, &data, &mode2,				&xa1, &xa2, &cdi,				&isize,				&nopreemp, &preemp,				&nopad, &pad, &bswab, getnum, &fs,				getbltype, &bltype, &pktsize,				&ispacket, &noclose) < 0) {			errmsgno(EX_BAD, "Bad Option: %s.\n", cav[0]);			usage(EX_BAD);		}		if (help)			usage(0);		if (tracks == 0) {			if (driver)				set_cdrcmds(driver, dpp);			if (version)				*flagsp |= F_VERSION;			if (checkdrive)				*flagsp |= F_CHECKDRIVE;			if (prcap)				*flagsp |= F_PRCAP;			if (inq)				*flagsp |= F_INQUIRY;			if (scanbus)				*flagsp |= F_SCANBUS;			if (reset)				*flagsp |= F_RESET;			if (ignsize)				*flagsp |= F_IGNSIZE;			if (load)				*flagsp |= F_LOAD;			if (eject)				*flagsp |= F_EJECT;			if (dummy)				*flagsp |= F_DUMMY;			if (msinfo)				*flagsp |= F_MSINFO;			if (toc)				*flagsp |= F_TOC;			if (multi) {				*flagsp |= F_MULTI;				tracktype = TOC_XA2;				sectype = ST_ROM_MODE2;				dbtype = DB_XA_MODE2;			}			if (fix)				*flagsp |= F_FIX;			if (nofix)				*flagsp |= F_NOFIX;			if (bltype >= 0) {				*flagsp |= F_BLANK;				*blankp = bltype;			}			version = checkdrive = prcap = inq = scanbus = reset = ignsize =			load = eject = dummy = msinfo = toc = multi = fix = nofix = 0;		} else if ((version + checkdrive + prcap + inq + scanbus + reset + ignsize +			    load + eject + dummy + msinfo + toc + multi + fix + nofix) > 0)			comerrno(EX_BAD, "Badly placed option. Global options must be before any track.\n");		if (nopreemp)			preemp = 0;		if (nopad)			pad = 0;		if ((audio + data + mode2 + xa1 + xa2 + cdi) > 1) {			errmsgno(EX_BAD, "Too many types for track %d.\n", tracks+1);			comerrno(EX_BAD, "Only one of -audio, -data, -mode2, -xa1, -xa2, -cdi allowed.\n");		}		if (ispacket && audio) {			comerrno(EX_BAD, "Audio data cannot be written in packet mode.\n");		}		if (data) {			tracktype = TOC_ROM;			sectype = ST_ROM_MODE1;			dbtype = DB_ROM_MODE1;		}		if (mode2) {			tracktype = TOC_ROM;			sectype = ST_ROM_MODE2;			dbtype = DB_ROM_MODE2;		}		if (audio) {			tracktype = TOC_DA;			sectype = preemp ? ST_AUDIO_PRE : ST_AUDIO_NOPRE;			dbtype = DB_RAW;		}		if (xa1) {			tracktype = TOC_XA1;			sectype = ST_ROM_MODE1;			dbtype = DB_XA_MODE1;		}		if (xa2) {			tracktype = TOC_XA2;			sectype = ST_ROM_MODE2;			dbtype = DB_XA_MODE2_F1;		}		if (cdi) {			tracktype = TOC_CDI;			sectype = ST_ROM_MODE2;			dbtype = DB_XA_MODE2_F1;		}		if (tracks == 0)			*toctypep = tracktype;		flags = 0;		if ((sectype & ST_AUDIOMASK) != 0)			flags |= TI_AUDIO;		if (isize) {			flags |= TI_ISOSIZE;			if ((*flagsp & F_MULTI) != 0)				comerrno(EX_BAD, "Cannot get isosize for multi session disks.\n");		}		if (preemp)			flags |= TI_PREEMP;		if ((flags & TI_AUDIO) == 0 && padsize > (Llong)0L)			pad = TRUE;		if (pad) {			flags |= TI_PAD;			if ((flags & TI_AUDIO) == 0 && padsize == (Llong)0L)				padsize = (Llong)PAD_SIZE;		}		if (bswab)			flags |= TI_SWAB;		if (ispacket) 			flags |= TI_PACKET;		if (noclose) 			flags |= TI_NOCLOSE;		if (getfiles(&cac, &cav, opts) == 0)			break;		tracks++;		if (tracks > MAX_TRACK)			comerrno(EX_BAD, "Track limit (%d) exceeded\n",								MAX_TRACK);		if (strcmp("-", cav[0]) == 0) {			trackp[tracks].f = STDIN_FILENO;		} else {			if (access(cav[0], R_OK) < 0)				comerr("No read access for '%s'.\n", cav[0]);			if ((trackp[tracks].f = open(cav[0], O_RDONLY|O_BINARY)) < 0)				comerr("Cannot open '%s'.\n", cav[0]);		}		if (!is_auname(cav[0]) && !is_wavname(cav[0]))			flags |= TI_NOAUHDR;		if (tracks == 1 && (pregapsize != -1L && pregapsize != 150))			pregapsize = -1L;		secsize = tracktype == TOC_DA ? AUDIO_SEC_SIZE : DATA_SEC_SIZE;		trackp[tracks].filename = cav[0];;		trackp[tracks].trackstart = 0L;		trackp[tracks].tracksize = tracksize;		trackp[tracks].pregapsize = pregapsize;		trackp[tracks].padsize = padsize;		trackp[tracks].secsize = secsize;		trackp[tracks].secspt = 0;	/* transfer size is set up in set_trsizes() */		trackp[tracks].pktsize = pktsize;		trackp[tracks].trackno = tracks;		trackp[tracks].sectype = sectype;		trackp[tracks].tracktype = tracktype;		trackp[tracks].dbtype = dbtype;		trackp[tracks].flags = flags;		checksize(&trackp[tracks]);		tracksize = trackp[tracks].tracksize;		if (tracksize > 0 && (tracksize / secsize) < 300) {			tracksize = roundup(tracksize, secsize);			padsize = tracksize + roundup(padsize, secsize);			if ((padsize / secsize) < 300) {				trackp[tracks].padsize =					300 * secsize - tracksize;			}		}		if (debug) {			printf("File: '%s' tracksize: %ld secsize: %d tracktype: %d = %s sectype: %X = %s dbtype: %s flags %X\n",				cav[0],	trackp[tracks].tracksize, 				trackp[tracks].secsize, 				tracktype, toc2name[tracktype & TOC_MASK],				sectype, st2name[sectype & ST_MASK], db2name[dbtype], flags);		}	}	if (fs < 0L && fs != -1L)		comerrno(EX_BAD, "Bad fifo size option.\n");	if (fs < 0L) {		char	*p = getenv("CDR_FIFOSIZE");		if (p) {			if (getnum(p, &fs) != 1)				comerrno(EX_BAD, "Bad fifo size environment.\n");		}	}	if (fs < 0L)		fs = DEFAULT_FIFOSIZE;	if (speed < 0 && speed != -1)		comerrno(EX_BAD, "Bad speed option.\n");	if (speed < 0) {		char	*p = getenv("CDR_SPEED");		if (p) {			speed = atoi(p);			if (speed < 0)				comerrno(EX_BAD, "Bad speed environment.\n");		}	}	if (speed >= 0)		*speedp = speed;	if (!*devp)		*devp = getenv("CDR_DEVICE");	if (!*devp && (*flagsp & (F_VERSION|F_SCANBUS)) == 0) {		errmsgno(EX_BAD, "No CD/DVD-Recorder device specified.\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -