xs/shared-ts/shared/DVBT-common.h

filter: Statementstmt 0.0% 0 / 6 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 8 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/mpeg2audio/utils.c ↑ Summary xs/shared-ts/DVBT-ts-shared-c.c »
1 /*---------------------------------------------------------------------------------------------------*/
2 #include <unistd.h>
3 #include "list.h"
4  
5 /*---------------------------------------------------------------------------------------------------*/
6  
7 /** ARRAY store macros **/
8  
9 #define AVS_H(arr, h) av_push(arr, newRV((SV *)h))
10 #define AVS_A(arr, a) av_push(arr, newRV((SV *)a))
11 #define AVS_I(arr, i) av_push(arr, newSViv(i))
12 #define AVS_S(arr, s) av_push(arr, newSVpv(s, 0))
13  
14  
15 /** HASH store macros **/
16  
17 /* Use 'name' as structure field name AND HASH key name */
18 #define HVS(h, name, sv) hv_store(h, #name, sizeof(#name)-1, sv, 0)
19 #define HVS_S(h, sp, name) if (sp->name) hv_store(h, #name, sizeof(#name)-1, newSVpv(sp->name, 0), 0)
20 #define HVS_I(h, sp, name) if (sp->name >= 0) hv_store(h, #name, sizeof(#name)-1, newSViv(sp->name), 0)
21 #define HVS_BIT(h, var, name) hv_store(h, #name, sizeof(#name)-1, newSViv(var & name ? 1 : 0), 0)
22  
23 /* Specify the structure field name and HASH key name separately */
24 #define HVSN_S(h, sp, name, key) if (sp->name) hv_store(h, #key, sizeof(#key)-1, newSVpv(sp->name, 0), 0)
25 #define HVSN_I(h, sp, name, key) if (sp->name >= 0) hv_store(h, #key, sizeof(#key)-1, newSViv(sp->name), 0)
26  
27 /* Convert string before storing in hash */
28 #define HVS_STRING(h, sp, name) hv_store(h, #name, sizeof(#name)-1, newSVpv(_to_string(sp->name), 0), 0)
29  
30 /* non-struct member versions */
31 #define HVS_INT(h, name, i) hv_store(h, #name, sizeof(#name)-1, newSViv(i), 0)
32 #define HVS_STR(h, name, s) hv_store(h, #name, sizeof(#name)-1, newSVpv(s, 0), 0)
33  
34  
35 /** HASH read macros **/
36 #define HVF_I(hv,var) \
37 if ( (val = hv_fetch (hv, #var, sizeof (#var) - 1, 0)) ) { \
38 if ( val != NULL ) { \
39 var = SvIV (*val); \
40 if (DVBT_DEBUG) fprintf(stderr, " set %s = %d\n", #var, var); \
41 } \
42 }
43  
44 #define HVF_SV(hv,var) \
45 if ( (val = hv_fetch (hv, #var, sizeof (#var) - 1, 0)) ) { \
46 if ( val != NULL ) { \
47 var = SvSV (*val); \
48 } \
49 }
50  
51 #define HVF_IV(hv,var,ival) \
52 if ( (val = hv_fetch (hv, #var, sizeof (#var) - 1, 0)) ) { \
53 if ( val != NULL ) { \
54 ival = SvIV (*val); \
55 } \
56 }
57  
58 #define HVF_SVV(hv,var,sval) \
59 if ( (val = hv_fetch (hv, #var, sizeof (#var) - 1, 0)) ) { \
60 if ( val != NULL ) { \
61 sval = (*val); \
62 } \
63 }
64  
65 #define HVF(hv, var) hv_fetch (hv, #var, sizeof (#var) - 1, 0)
66  
67  
68 /* get the HASH ref using the specified key. If not currently set, then create a new HASH and add it to the parent */
69 #define GET_HREF(hv, key, var) \
70 if ( (val = hv_fetch (hv, #key, sizeof (#key) - 1, 0)) ) { \
71 if ( val != NULL ) { \
72 var = (HV *)sv_2mortal(*val); \
73 } \
74 else { \
75 var = (HV *)sv_2mortal((SV *)newHV()); \
76 hv_store(hv, #key, sizeof(#key)-1, newRV((SV *)var), 0) ; \
77 } \
78 }
79  
80  
81 /*---------------------------------------------------------------------------------------------------*/
82 0 static char *_to_string(char *str)
83 {
84 0 int i, j, len = strlen(str);
85 static char ret_str[8192] ;
86  
87 0 ▶ for (i=0, j=0; i < len; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i=0, j=0; i < len; i++) 0 0 0
88 {
89 0 ret_str[j++] = str[i] ;
90  
91 /* terminate */
92 0 ret_str[j] = 0 ;
93 }
94 0 return ret_str ;
95 }
96  
« clib/mpeg2audio/utils.c ↑ Summary xs/shared-ts/DVBT-ts-shared-c.c »