comparison remap.c @ 388:90ca650854e0 src

Remove all trailing whitespace, patch by Erik Hovland *erik$hovland dot org%
author rathann
date Sat, 06 Sep 2008 21:55:51 +0000
parents 579a3538d284
children d3c273ced49c
comparison
equal deleted inserted replaced
387:4e28052eb201 388:90ca650854e0
24 24
25 #include <stdlib.h> 25 #include <stdlib.h>
26 #include <string.h> 26 #include <string.h>
27 #include <stdio.h> 27 #include <stdio.h>
28 28
29 #ifndef _MSC_VER 29 #ifndef _MSC_VER
30 #include <sys/param.h> 30 #include <sys/param.h>
31 #include <sys/fcntl.h> 31 #include <sys/fcntl.h>
32 #else 32 #else
33 #ifndef MAXPATHLEN 33 #ifndef MAXPATHLEN
34 #define MAXPATHLEN 255 34 #define MAXPATHLEN 255
96 if (a->end_block < b->start_block) { 96 if (a->end_block < b->start_block) {
97 return -1; 97 return -1;
98 } else if (a->start_block > b->end_block) { 98 } else if (a->start_block > b->end_block) {
99 /* 99 /*
100 * if a->start_block == b->end_block then the two regions 100 * if a->start_block == b->end_block then the two regions
101 * aren't strictly overlapping, but they should be merged 101 * aren't strictly overlapping, but they should be merged
102 * anyway since there are zero blocks between them 102 * anyway since there are zero blocks between them
103 */ 103 */
104 return 1; 104 return 1;
105 } 105 }
106 106
152 } 152 }
153 map->blocks[ n] = block; 153 map->blocks[ n] = block;
154 } 154 }
155 } 155 }
156 156
157 static int parseblock(char *buf, int *dom, int *tt, int *pg, 157 static int parseblock(char *buf, int *dom, int *tt, int *pg,
158 unsigned long *start, unsigned long *end) { 158 unsigned long *start, unsigned long *end) {
159 long tmp; 159 long tmp;
160 char *tok; 160 char *tok;
161 char *epos; 161 char *epos;
162 char *marker[]={"domain", "title", "program", "start", "end"}; 162 char *marker[]={"domain", "title", "program", "start", "end"};
182 *start = tmp; 182 *start = tmp;
183 break; 183 break;
184 case 4: 184 case 4:
185 *end = tmp; 185 *end = tmp;
186 break; 186 break;
187 } 187 }
188 st++; 188 st++;
189 tok = strtok( NULL, " "); 189 tok = strtok( NULL, " ");
190 } 190 }
191 return st; 191 return st;
192 } 192 }
221 while (fgets( buf, sizeof(buf), fp) != NULL) { 221 while (fgets( buf, sizeof(buf), fp) != NULL) {
222 if (buf[0] == '\n' || buf[0] == '#' || buf[0] == 0) continue; 222 if (buf[0] == '\n' || buf[0] == '#' || buf[0] == 0) continue;
223 if (strncasecmp( buf, "debug", 5) == 0) { 223 if (strncasecmp( buf, "debug", 5) == 0) {
224 map->debug = 1; 224 map->debug = 1;
225 } else { 225 } else {
226 res = parseblock( buf, 226 res = parseblock( buf,
227 &tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block); 227 &tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block);
228 if (res != 5) { 228 if (res != 5) {
229 fprintf(MSG_OUT, "libdvdnav: Ignoring map line (%d): %s\n", res, buf); 229 fprintf(MSG_OUT, "libdvdnav: Ignoring map line (%d): %s\n", res, buf);
230 continue; 230 continue;
231 } 231 }
239 return NULL; 239 return NULL;
240 } 240 }
241 return map; 241 return map;
242 } 242 }
243 243
244 unsigned long remap_block( 244 unsigned long remap_block(
245 remap_t *map, int domain, int title, int program, 245 remap_t *map, int domain, int title, int program,
246 unsigned long cblock, unsigned long offset) 246 unsigned long cblock, unsigned long offset)
247 { 247 {
248 block_t key; 248 block_t key;
249 block_t *b; 249 block_t *b;
250 250
251 if (map->debug) { 251 if (map->debug) {
256 key.domain = domain; 256 key.domain = domain;
257 key.title = title; 257 key.title = title;
258 key.program = program; 258 key.program = program;
259 key.start_block = key.end_block = cblock + offset; 259 key.start_block = key.end_block = cblock + offset;
260 b = findblock( map, &key); 260 b = findblock( map, &key);
261 261
262 if (b) { 262 if (b) {
263 if (map->debug) { 263 if (map->debug) {
264 fprintf(MSG_OUT, "libdvdnav: Redirected to %lx\n", b->end_block); 264 fprintf(MSG_OUT, "libdvdnav: Redirected to %lx\n", b->end_block);
265 } 265 }
266 return b->end_block - cblock; 266 return b->end_block - cblock;