| 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_list(char *fn, struct list_head *cut_list) |
| 30 |
|
| { |
| 31 |
|
| struct list_head *item, *safe; |
| 32 |
|
| struct TS_cut *cutitem; |
| 33 |
0 |
| unsigned count=0 ; |
| 34 |
|
| |
| 35 |
0 |
| printf("\n\n--- print_cut_list(%s, cut_list @ %p) ---\n", fn, cut_list) ; |
| 36 |
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 |
|
| 37 |
|
| { |
| 38 |
0 |
| cutitem = list_entry(item, struct TS_cut, next); |
| 39 |
0 |
| printf(" + item @ %p start=%u, end=%u magic=0x%08x {list @ %p => next %p, prev %p}\n", |
| 40 |
|
| cutitem, |
| 41 |
|
| cutitem->start, cutitem->end, cutitem->magic, |
| 42 |
|
| cutitem->next, cutitem->next.next, cutitem->next.prev) ; |
| 43 |
|
| |
| 44 |
0 |
▶ | if (cutitem->magic != TS_SKIP_MAGIC) abort() ; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cutitem->magic != TS_SKIP_MAGIC) abort() ; |
0 |
0 |
0 |
|
| 45 |
0 |
▶ | if (++count >= 10) abort() ; |
Branch: 1 branch
| Branch | True | False | Total |
| if (++count >= 10) abort() ; |
0 |
0 |
0 |
|
| 46 |
|
| }; |
| 47 |
|
| |
| 48 |
0 |
| printf("\n\n--- print_cut_list(cut_list @ %p) END ---\n", cut_list) ; |
| 49 |
0 |
| } |
| 50 |
|
| |
| 51 |
|
| |
| 52 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 53 |
0 |
| void free_cut_list(struct list_head *cut_list) |
| 54 |
|
| { |
| 55 |
|
| struct list_head *item, *safe; |
| 56 |
|
| struct TS_cut *cutitem; |
| 57 |
|
| |
| 58 |
|
| |
| 59 |
|
| // _print_cut_list("free_cut_list", cut_list) ; |
| 60 |
|
| |
| 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 |
0 |
| list_del(&cutitem->next); |
| 65 |
0 |
| free(cutitem); |
| 66 |
|
| }; |
| 67 |
|
| |
| 68 |
0 |
| } |
| 69 |
|
| |
| 70 |
|
| |
| 71 |
|
| //--------------------------------------------------------------------------------------------------------- |
| 72 |
0 |
| void remove_ext(char *src, char *dest) |
| 73 |
|
| { |
| 74 |
|
| char *p ; |
| 75 |
|
| |
| 76 |
0 |
| strcpy(dest, src) ; |
| 77 |
|
| |
| 78 |
|
| // replace rindex() |
| 79 |
0 |
| p = dest + strlen(dest) - 1 ; |
| 80 |
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 |
|
| 81 |
|
| { |
| 82 |
0 |
| --p ; |
| 83 |
|
| } |
| 84 |
|
| |
| 85 |
0 |
▶ | if (*p == '.') *p = 0 ; |
Branch: 1 branch
| Branch | True | False | Total |
| if (*p == '.') *p = 0 ; |
0 |
0 |
0 |
|
| 86 |
0 |
| } |