/[debburn]/nonameyet/branches/cleanup/cdrecord/movesect.c
ViewVC logotype

Contents of /nonameyet/branches/cleanup/cdrecord/movesect.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 248 - (show annotations) (download)
Mon Sep 11 07:17:29 2006 UTC (6 years, 8 months ago) by blade
File MIME type: text/plain
File size: 2873 byte(s)
  [ Christian Fromme ]
  * big cleanup, phase I, getting rid from Cstyle function definitions in
    applications
1 /*
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 /* @(#)movesect.c 1.3 04/03/02 Copyright 2001, 2004 J. Schilling */
14 #ifndef lint
15 static char sccsid[] =
16 "@(#)movesect.c 1.3 04/03/02 Copyright 2001, 2004 J. Schilling";
17 #endif
18 /*
19 * Copyright (c) 2001, 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 <standard.h>
38 #include <utypes.h>
39 #include <schily.h>
40
41 #include "cdrecord.h"
42 #include "movesect.h"
43
44 void scatter_secs __PR((track_t *trackp, char *bp, int nsecs));
45
46 /*
47 * Scatter input sector size records over buffer to make them
48 * output sector size.
49 *
50 * If input sector size is less than output sector size,
51 *
52 * | sector_0 || sector_1 || ... || sector_n ||
53 *
54 * will be convterted into:
55 *
56 * | sector_0 |grass|| sector_1 |grass|| ... || sector_n |grass||
57 *
58 * Sector_n must me moved n * grass_size forward,
59 * Sector_1 must me moved 1 * grass_size forward
60 *
61 *
62 * If output sector size is less than input sector size,
63 *
64 * | sector_0 |grass|| sector_1 |grass|| ... || sector_n |grass||
65 *
66 * will be convterted into:
67 *
68 * | sector_0 || sector_1 || ... || sector_n ||
69 *
70 * Sector_1 must me moved 1 * grass_size backward,
71 * Sector_n must me moved n * grass_size backward,
72 *
73 * Sector_0 must never be moved.
74 */
75 void
76 scatter_secs(track_t *trackp, char *bp, int nsecs)
77 {
78 char *from;
79 char *to;
80 int isecsize = trackp->isecsize;
81 int secsize = trackp->secsize;
82 int i;
83
84 if (secsize == isecsize)
85 return;
86
87 nsecs -= 1; /* we do not move sector # 0 */
88
89 if (secsize < isecsize) {
90 from = bp + isecsize;
91 to = bp + secsize;
92
93 for (i = nsecs; i > 0; i--) {
94 movebytes(from, to, secsize);
95 from += isecsize;
96 to += secsize;
97 }
98 } else {
99 from = bp + (nsecs * isecsize);
100 to = bp + (nsecs * secsize);
101
102 for (i = nsecs; i > 0; i--) {
103 movebytes(from, to, isecsize);
104 from -= isecsize;
105 to -= secsize;
106 }
107 }
108 }

  ViewVC Help
Powered by ViewVC 1.1.5