File: | root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/registry/c2ru.c |
Warning: | line 283, column 24 Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * |
3 | * c2ru.c |
4 | * |
5 | * $Source: /Users/ekr/tmp/nrappkit-dump/nrappkit/src/registry/c2ru.c,v $ |
6 | * $Revision: 1.3 $ |
7 | * $Date: 2007/06/26 22:37:50 $ |
8 | * |
9 | * c2r utility methods |
10 | * |
11 | * |
12 | * Copyright (C) 2005, Network Resonance, Inc. |
13 | * Copyright (C) 2006, Network Resonance, Inc. |
14 | * All Rights Reserved |
15 | * |
16 | * Redistribution and use in source and binary forms, with or without |
17 | * modification, are permitted provided that the following conditions |
18 | * are met: |
19 | * |
20 | * 1. Redistributions of source code must retain the above copyright |
21 | * notice, this list of conditions and the following disclaimer. |
22 | * 2. Redistributions in binary form must reproduce the above copyright |
23 | * notice, this list of conditions and the following disclaimer in the |
24 | * documentation and/or other materials provided with the distribution. |
25 | * 3. Neither the name of Network Resonance, Inc. nor the name of any |
26 | * contributors to this software may be used to endorse or promote |
27 | * products derived from this software without specific prior written |
28 | * permission. |
29 | * |
30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' |
31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
34 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
36 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
38 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
40 | * POSSIBILITY OF SUCH DAMAGE. |
41 | * |
42 | * |
43 | */ |
44 | |
45 | #include <sys/queue.h> |
46 | #include <string.h> |
47 | #include <registry.h> |
48 | #include "nr_common.h" |
49 | #include <r_errors.h> |
50 | #include <r_macros.h> |
51 | #include <ctype.h> |
52 | #include "c2ru.h" |
53 | |
54 | |
55 | #define NRGET(func, type, get)int func(NR_registry parent, char *child, type **out) { int r , _status; NR_registry registry; type tmp; if ((r = nr_c2ru_make_registry (parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status =_r; goto abort;} while(0); if ((r = get(registry, &tmp)) ) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out = 0; } else { *out = r_calloc(0,1,sizeof (tmp)); if (*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status =_r; goto abort;} while(0); **out = tmp; } _status = 0; abort : return (_status); } \ |
56 | int \ |
57 | func(NR_registry parent, char *child, type **out) \ |
58 | { \ |
59 | int r, _status; \ |
60 | NR_registry registry; \ |
61 | type tmp; \ |
62 | \ |
63 | if ((r = nr_c2ru_make_registry(parent, child, registry))) \ |
64 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); \ |
65 | \ |
66 | if ((r = get(registry, &tmp))) { \ |
67 | if (r != R_NOT_FOUND2) \ |
68 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); \ |
69 | *out = 0; \ |
70 | } \ |
71 | else { \ |
72 | *out = RCALLOC(sizeof(tmp))r_calloc(0,1,sizeof(tmp)); \ |
73 | if (*out == 0) \ |
74 | ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); \ |
75 | **out = tmp; \ |
76 | } \ |
77 | \ |
78 | _status = 0; \ |
79 | abort: \ |
80 | return (_status); \ |
81 | } |
82 | |
83 | int |
84 | nr_c2ru_get_char(NR_registry parent, char *child, char **out) |
85 | { |
86 | int r, _status; |
87 | NR_registry registry; |
88 | char tmp; |
89 | |
90 | if ((r = nr_c2ru_make_registry(parent, child, registry))) |
91 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
92 | |
93 | if ((r = NR_reg_get_char(registry, &tmp))) { |
94 | if (r != R_NOT_FOUND2) |
95 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
96 | *out = 0; |
97 | } |
98 | else { |
99 | *out = RCALLOC(sizeof(tmp))r_calloc(0,1,sizeof(tmp)); |
100 | if (*out == 0) |
101 | ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
102 | **out = tmp; |
103 | } |
104 | |
105 | _status = 0; |
106 | abort: |
107 | return (_status); |
108 | } |
109 | NRGET(nr_c2ru_get_uchar, UCHAR, NR_reg_get_uchar)int nr_c2ru_get_uchar(NR_registry parent, char *child, UCHAR * *out) { int r, _status; NR_registry registry; UCHAR tmp; if ( (r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_get_uchar(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while( 0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
110 | NRGET(nr_c2ru_get_int2, INT2, NR_reg_get_int2)int nr_c2ru_get_int2(NR_registry parent, char *child, INT2 ** out) { int r, _status; NR_registry registry; INT2 tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r =r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if (( r = NR_reg_get_int2(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0 ) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); **out = tmp; } _status = 0; abort: return (_status); } |
111 | NRGET(nr_c2ru_get_uint2, UINT2, NR_reg_get_uint2)int nr_c2ru_get_uint2(NR_registry parent, char *child, UINT2 * *out) { int r, _status; NR_registry registry; UINT2 tmp; if ( (r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_get_uint2(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while( 0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
112 | NRGET(nr_c2ru_get_int4, INT4, NR_reg_get_int4)int nr_c2ru_get_int4(NR_registry parent, char *child, INT4 ** out) { int r, _status; NR_registry registry; INT4 tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r =r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if (( r = NR_reg_get_int4(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0 ) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); **out = tmp; } _status = 0; abort: return (_status); } |
113 | NRGET(nr_c2ru_get_uint4, UINT4, NR_reg_get_uint4)int nr_c2ru_get_uint4(NR_registry parent, char *child, UINT4 * *out) { int r, _status; NR_registry registry; UINT4 tmp; if ( (r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_get_uint4(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while( 0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
114 | NRGET(nr_c2ru_get_int8, INT8, NR_reg_get_int8)int nr_c2ru_get_int8(NR_registry parent, char *child, INT8 ** out) { int r, _status; NR_registry registry; INT8 tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r =r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if (( r = NR_reg_get_int8(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0 ) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); **out = tmp; } _status = 0; abort: return (_status); } |
115 | NRGET(nr_c2ru_get_uint8, UINT8, NR_reg_get_uint8)int nr_c2ru_get_uint8(NR_registry parent, char *child, UINT8 * *out) { int r, _status; NR_registry registry; UINT8 tmp; if ( (r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_get_uint8(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while( 0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
116 | NRGET(nr_c2ru_get_double, double, NR_reg_get_double)int nr_c2ru_get_double(NR_registry parent, char *child, double **out) { int r, _status; NR_registry registry; double tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_get_double(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while( 0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
117 | NRGET(nr_c2ru_get_string, char*, NR_reg_alloc_string)int nr_c2ru_get_string(NR_registry parent, char *child, char* **out) { int r, _status; NR_registry registry; char* tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((r = NR_reg_alloc_string(registry, &tmp))) { if (r != 2 ) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if ( *out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
118 | NRGET(nr_c2ru_get_data, Data, NR_reg_alloc_data)int nr_c2ru_get_data(NR_registry parent, char *child, Data ** out) { int r, _status; NR_registry registry; Data tmp; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r =r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if (( r = NR_reg_alloc_data(registry, &tmp))) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0) ; *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort ;} while(0); **out = tmp; } _status = 0; abort: return (_status ); } |
119 | |
120 | |
121 | #define NRSET(func, type, set)int func(NR_registry parent, char *child, type *in) { int r, _status ; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry (parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status =_r; goto abort;} while(0); if ((r = set(registry, *in))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0) ; _status = 0; abort: return (_status); } \ |
122 | int \ |
123 | func(NR_registry parent, char *child, type *in) \ |
124 | { \ |
125 | int r, _status; \ |
126 | NR_registry registry; \ |
127 | \ |
128 | if (in == 0) \ |
129 | return 0; \ |
130 | \ |
131 | if ((r = nr_c2ru_make_registry(parent, child, registry))) \ |
132 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); \ |
133 | \ |
134 | if ((r = set(registry, *in))) \ |
135 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); \ |
136 | \ |
137 | _status = 0; \ |
138 | abort: \ |
139 | return (_status); \ |
140 | } |
141 | |
142 | NRSET(nr_c2ru_set_char, char, NR_reg_set_char)int nr_c2ru_set_char(NR_registry parent, char *child, char *in ) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_char(registry, *in))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
143 | NRSET(nr_c2ru_set_uchar, UCHAR, NR_reg_set_uchar)int nr_c2ru_set_uchar(NR_registry parent, char *child, UCHAR * in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_uchar(registry, *in))) do { int _r=r ; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
144 | NRSET(nr_c2ru_set_int2, INT2, NR_reg_set_int2)int nr_c2ru_set_int2(NR_registry parent, char *child, INT2 *in ) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_int2(registry, *in))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
145 | NRSET(nr_c2ru_set_uint2, UINT2, NR_reg_set_uint2)int nr_c2ru_set_uint2(NR_registry parent, char *child, UINT2 * in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_uint2(registry, *in))) do { int _r=r ; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
146 | NRSET(nr_c2ru_set_int4, INT4, NR_reg_set_int4)int nr_c2ru_set_int4(NR_registry parent, char *child, INT4 *in ) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_int4(registry, *in))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
147 | NRSET(nr_c2ru_set_uint4, UINT4, NR_reg_set_uint4)int nr_c2ru_set_uint4(NR_registry parent, char *child, UINT4 * in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_uint4(registry, *in))) do { int _r=r ; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
148 | NRSET(nr_c2ru_set_int8, INT8, NR_reg_set_int8)int nr_c2ru_set_int8(NR_registry parent, char *child, INT8 *in ) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_int8(registry, *in))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
149 | NRSET(nr_c2ru_set_uint8, UINT8, NR_reg_set_uint8)int nr_c2ru_set_uint8(NR_registry parent, char *child, UINT8 * in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_uint8(registry, *in))) do { int _r=r ; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
150 | NRSET(nr_c2ru_set_double, double, NR_reg_set_double)int nr_c2ru_set_double(NR_registry parent, char *child, double *in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_double(registry, *in))) do { int _r= r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
151 | NRSET(nr_c2ru_set_string, char*, NR_reg_set_string)int nr_c2ru_set_string(NR_registry parent, char *child, char* *in) { int r, _status; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); if ((r = NR_reg_set_string(registry, *in))) do { int _r= r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status = 0; abort: return (_status); } |
152 | |
153 | int |
154 | nr_c2ru_set_data(NR_registry parent, char *child, Data *in) |
155 | { |
156 | int r, _status; |
157 | NR_registry registry; |
158 | |
159 | if (in == 0) |
160 | return 0; |
161 | |
162 | if ((r = nr_c2ru_make_registry(parent, child, registry))) |
163 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
164 | |
165 | if ((r = NR_reg_set_bytes(registry, in->data, in->len))) |
166 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
167 | |
168 | _status = 0; |
169 | abort: |
170 | return (_status); |
171 | } |
172 | |
173 | #define NRFREE(func, type)int func(type *in) { if (in) if(in) r_free(in); return 0; } \ |
174 | int \ |
175 | func(type *in) \ |
176 | { \ |
177 | if (in) \ |
178 | RFREE(in)if(in) r_free(in); \ |
179 | return 0; \ |
180 | } |
181 | |
182 | NRFREE(nr_c2ru_free_char, char)int nr_c2ru_free_char(char *in) { if (in) if(in) r_free(in); return 0; } |
183 | NRFREE(nr_c2ru_free_uchar, UCHAR)int nr_c2ru_free_uchar(UCHAR *in) { if (in) if(in) r_free(in) ; return 0; } |
184 | NRFREE(nr_c2ru_free_int2, INT2)int nr_c2ru_free_int2(INT2 *in) { if (in) if(in) r_free(in); return 0; } |
185 | NRFREE(nr_c2ru_free_uint2, UINT2)int nr_c2ru_free_uint2(UINT2 *in) { if (in) if(in) r_free(in) ; return 0; } |
186 | NRFREE(nr_c2ru_free_int4, INT4)int nr_c2ru_free_int4(INT4 *in) { if (in) if(in) r_free(in); return 0; } |
187 | NRFREE(nr_c2ru_free_uint4, UINT4)int nr_c2ru_free_uint4(UINT4 *in) { if (in) if(in) r_free(in) ; return 0; } |
188 | NRFREE(nr_c2ru_free_int8, INT8)int nr_c2ru_free_int8(INT8 *in) { if (in) if(in) r_free(in); return 0; } |
189 | NRFREE(nr_c2ru_free_uint8, UINT8)int nr_c2ru_free_uint8(UINT8 *in) { if (in) if(in) r_free(in) ; return 0; } |
190 | NRFREE(nr_c2ru_free_double, double)int nr_c2ru_free_double(double *in) { if (in) if(in) r_free(in ); return 0; } |
191 | |
192 | |
193 | int |
194 | nr_c2ru_free_string(char **in) |
195 | { |
196 | if (*in) |
197 | RFREE(*in)if(*in) r_free(*in); |
198 | if (in) |
199 | RFREE(in)if(in) r_free(in); |
200 | return 0; |
201 | } |
202 | |
203 | int |
204 | nr_c2ru_free_data(Data *in) |
205 | { |
206 | int r, _status; |
207 | |
208 | if (in) { |
209 | if ((r=r_data_destroy(&in))) |
210 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
211 | } |
212 | |
213 | _status = 0; |
214 | abort: |
215 | return (_status); |
216 | } |
217 | |
218 | int |
219 | nr_c2ru_get_children(NR_registry parent, char *child, void *ptr, size_t size, int (*get)(NR_registry, void*)) |
220 | { |
221 | int r, _status; |
222 | NR_registry registry; |
223 | unsigned int count; |
224 | unsigned int i; |
225 | NR_registry name; |
226 | struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry; |
227 | TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr; |
228 | |
229 | TAILQ_INIT(tailq)do { (((tailq))->tqh_first) = ((void*)0); (tailq)->tqh_last = &(((tailq))->tqh_first); ; } while (0); |
230 | |
231 | if ((r=nr_c2ru_make_registry(parent, child, registry))) |
232 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
233 | |
234 | if ((r=NR_reg_get_child_count(registry, &count))) { |
235 | if (r != R_NOT_FOUND2) |
236 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
237 | } |
238 | else { |
239 | for (i = 0; i < count; ++i) { |
240 | if ((r=NR_reg_get_child_registry(registry, i, name))) { |
241 | /* ignore R_NOT_FOUND errors */ |
242 | if (r == R_NOT_FOUND2) |
243 | continue; |
244 | else |
245 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
246 | } |
247 | |
248 | if ((r=get(name, &entry))) { |
249 | /* ignore R_NOT_FOUND errors */ |
250 | if (r == R_NOT_FOUND2) |
251 | continue; |
252 | else |
253 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
254 | } |
255 | |
256 | TAILQ_INSERT_TAIL(tailq, entry, entries)do { (((entry))->entries.tqe_next) = ((void*)0); (entry)-> entries.tqe_prev = (tailq)->tqh_last; *(tailq)->tqh_last = (entry); (tailq)->tqh_last = &(((entry))->entries .tqe_next); ; ; } while (0); |
257 | } |
258 | } |
259 | |
260 | _status = 0; |
261 | abort: |
262 | return (_status); |
263 | } |
264 | |
265 | int |
266 | nr_c2ru_set_children(NR_registry parent, char *child, void *ptr, int (*set)(NR_registry, void*), int (*label)(NR_registry, void*, char[NR_REG_MAX_NR_REGISTRY_LEN128])) |
267 | { |
268 | int r, _status; |
269 | NR_registry registry; |
270 | int i; |
271 | NR_registry name; |
272 | char buffer[NR_REG_MAX_NR_REGISTRY_LEN128]; |
273 | struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry; |
274 | TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr; |
275 | |
276 | if ((r=nr_c2ru_make_registry(parent, child, registry))) |
277 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
278 | |
279 | (void)NR_reg_del(registry); |
280 | |
281 | i = 0; |
282 | TAILQ_FOREACH(entry, tailq, entries)for ((entry) = (((tailq))->tqh_first); (entry); (entry) = ( ((entry))->entries.tqe_next)) { |
283 | if (label == 0 || (r=label(registry, entry, buffer))) { |
Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r' | |
284 | snprintf(buffer, sizeof(buffer), "%d", i); |
285 | } |
286 | if ((r=nr_c2ru_make_registry(registry, buffer, name))) |
287 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
288 | |
289 | if ((r=set(name, entry))) |
290 | ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while (0); |
291 | |
292 | ++i; |
293 | } |
294 | |
295 | _status = 0; |
296 | abort: |
297 | return (_status); |
298 | } |
299 | |
300 | int |
301 | nr_c2ru_free_children(void *ptr, int (*free)(void*)) |
302 | { |
303 | struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry; |
304 | TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr; |
305 | |
306 | while (! TAILQ_EMPTY(tailq)((tailq)->tqh_first == ((void*)0))) { |
307 | entry = TAILQ_FIRST(tailq)((tailq)->tqh_first); |
308 | TAILQ_REMOVE(tailq, entry, entries)do { if (((((entry))->entries.tqe_next)) != ((void*)0)) (( (entry))->entries.tqe_next)->entries.tqe_prev = (entry) ->entries.tqe_prev; else { (tailq)->tqh_last = (entry)-> entries.tqe_prev; ; } *(entry)->entries.tqe_prev = (((entry ))->entries.tqe_next); ; ; ; } while (0); |
309 | (void)free(entry); |
310 | } |
311 | |
312 | return 0; |
313 | } |
314 | |
315 | /* requires parent already in legal form */ |
316 | int |
317 | nr_c2ru_make_registry(NR_registry parent, char *child, NR_registry out) |
318 | { |
319 | return NR_reg_make_registry(parent, child, out); |
320 | } |