| 1 |
|
| /* |
| 2 |
|
| * ts_skip.c |
| 3 |
|
| * |
| 4 |
|
| * Created on: 25 Jan 2011 |
| 5 |
|
| * Author: sdprice1 |
| 6 |
|
| */ |
| 7 |
|
| |
| 8 |
|
| #include "ts_skip.h" |
| 9 |
|
| |
| 10 |
|
| //======================================================================================================== |
| 11 |
|
| // SKIP |
| 12 |
|
| //======================================================================================================== |
| 13 |
|
| |
| 14 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 15 |
0 |
| void add_cut(struct list_head *cut_list, unsigned start, unsigned end) |
| 16 |
|
| { |
| 17 |
|
| struct TS_cut *cutitem; |
| 18 |
|
| |
| 19 |
0 |
| cutitem = malloc(sizeof(*cutitem)); |
| 20 |
0 |
| CLEAR_MEM(cutitem); |
| 21 |
0 |
| list_add_tail(&cutitem->next, cut_list); |
| 22 |
|
| |
| 23 |
0 |
| cutitem->start = start ; |
| 24 |
0 |
| cutitem->end = end ; |
| 25 |
0 |
| cutitem->magic = TS_SKIP_MAGIC ; |
| 26 |
0 |
| } |
| 27 |
|
| |
| 28 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 29 |
0 |
| void _print_cut_item(struct TS_cut *cutitem) |
| 30 |
|
| { |
| 31 |
|
| |
| 32 |
0 |
| fprintf(stderr, "item @ %p ", cutitem) ; |
| 33 |
0 |
▶ | if (cutitem == UNSET_CUT_LIST) |
Branch: 1 branch
| Branch | True | False | Total |
| if (cutitem == UNSET_CUT_LIST) |
0 |
0 |
0 |
|
| 34 |
|
| { |
| 35 |
0 |
| fprintf(stderr, "UNSET_CUT_LIST\n") ; |
| 36 |
|
| } |
| 37 |
0 |
▶ | else if (cutitem == END_CUT_LIST) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (cutitem == END_CUT_LIST) |
0 |
0 |
0 |
|
| 38 |
|
| { |
| 39 |
0 |
| fprintf(stderr, "END_CUT_LIST\n") ; |
| 40 |
|
| } |
| 41 |
|
| else |
| 42 |
|
| { |
| 43 |
0 |
▶ | if (cutitem->magic != TS_SKIP_MAGIC) fprintf(stderr, "\n!!ERROR: Cut item invalid!!\n") ; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cutitem->magic != TS_SKIP_MAGIC) fprintf(stderr, "\n!!ERROR: Cut item invalid!!\n") ; |
0 |
0 |
0 |
|
| 44 |
0 |
| fprintf(stderr, "start=%u, end=%u magic=0x%08x {list @ %p => next %p, prev %p}\n", |
| 45 |
|
| cutitem, |
| 46 |
|
| cutitem->start, cutitem->end, cutitem->magic, |
| 47 |
|
| cutitem->next, cutitem->next.next, cutitem->next.prev) ; |
| 48 |
|
| |
| 49 |
|
| } |
| 50 |
0 |
| } |
| 51 |
|
| |
| 52 |
|
| |
| 53 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 54 |
0 |
| void _print_cut_list(char *fn, struct list_head *cut_list) |
| 55 |
|
| { |
| 56 |
|
| struct list_head *item, *safe; |
| 57 |
|
| struct TS_cut *cutitem; |
| 58 |
0 |
| unsigned count=0 ; |
| 59 |
|
| |
| 60 |
0 |
| fprintf(stderr, "\n\n--- print_cut_list(%s, cut_list @ %p) ---\n", fn, cut_list) ; |
| 61 |
0 |
▶ | list_for_each_safe(item,safe,cut_list) |
Branch: 1 branch
| Branch | True | False | Total |
| list_for_each_safe(item,safe,cut_list) |
0 |
0 |
0 |
|
| 62 |
|
| { |
| 63 |
0 |
| cutitem = list_entry(item, struct TS_cut, next); |
| 64 |
|
| |
| 65 |
0 |
| fprintf(stderr, "[%2d] ", count) ; _print_cut_item(cutitem) ; |
| 66 |
|
| |
| 67 |
0 |
▶ | if (++count >= 30) |
Branch: 1 branch
| Branch | True | False | Total |
| if (++count >= 30) |
0 |
0 |
0 |
|
| 68 |
|
| { |
| 69 |
0 |
| fprintf(stderr, "!!ERROR: Too many cuts!!\n") ; |
| 70 |
0 |
| exit(10) ; |
| 71 |
|
| } |
| 72 |
|
| }; |
| 73 |
|
| |
| 74 |
0 |
| fprintf(stderr, "\n\n--- print_cut_list(cut_list @ %p) END ---\n", cut_list) ; |
| 75 |
0 |
| } |
| 76 |
|
| |
| 77 |
|
| |
| 78 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 79 |
0 |
| void free_cut_list(struct list_head *cut_list) |
| 80 |
|
| { |
| 81 |
|
| struct list_head *item, *safe; |
| 82 |
|
| struct TS_cut *cutitem; |
| 83 |
|
| |
| 84 |
|
| |
| 85 |
|
| // _print_cut_list("free_cut_list", cut_list) ; |
| 86 |
|
| |
| 87 |
0 |
▶ | list_for_each_safe(item,safe,cut_list) |
Branch: 1 branch
| Branch | True | False | Total |
| list_for_each_safe(item,safe,cut_list) |
0 |
0 |
0 |
|
| 88 |
|
| { |
| 89 |
0 |
| cutitem = list_entry(item, struct TS_cut, next); |
| 90 |
0 |
| list_del(&cutitem->next); |
| 91 |
0 |
| free(cutitem); |
| 92 |
|
| }; |
| 93 |
|
| |
| 94 |
0 |
| } |
| 95 |
|
| |
| 96 |
|
| |
| 97 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 98 |
0 |
| void remove_ext(char *src, char *dest) |
| 99 |
|
| { |
| 100 |
|
| char *p ; |
| 101 |
|
| |
| 102 |
0 |
| strncpy(dest, src, MAX_PATH_LEN) ; |
| 103 |
|
| |
| 104 |
|
| // replace rindex() |
| 105 |
0 |
| p = dest + strlen(dest) - 1 ; |
| 106 |
0 |
▶ | while ((p != dest) && (*p != '.')) |
Branch: 2 branches
| Branch | True | False | Total |
| while ((p != dest) && (*p != '.')) |
0 |
0 |
0 |
| while ((p != dest) && (*p != '.')) |
0 |
0 |
0 |
|
| 107 |
|
| { |
| 108 |
0 |
| --p ; |
| 109 |
|
| } |
| 110 |
|
| |
| 111 |
0 |
▶ | if (*p == '.') *p = 0 ; |
Branch: 1 branch
| Branch | True | False | Total |
| if (*p == '.') *p = 0 ; |
0 |
0 |
0 |
|
| 112 |
0 |
| } |