50ef50ca0feff355d81b241d36a2c6dda48f2c54
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

1) /*
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

2)  * EtherPix library
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

3)  *
Stefan Schuermans update copyright year

Stefan Schuermans authored 7 years ago

4)  * Copyright 2010-2017 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <errno.h>
21) #include <stdio.h>
22) #include <stdlib.h>
23) #include <string.h>
24) 
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

25) #include <etherpix/msg.h>
26) #include <etherpix/types.h>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

27) #include <intern/const_data.h>
28) #include <intern/constants.h>
29) #include <intern/config.h>
30) #include <intern/mapping.h>
Stefan Schuermans v1.0.6

Stefan Schuermans authored 13 years ago

31) #include <intern/missing.h>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

32) #include <intern/net.h>
33) #include <intern/parse.h>
Stefan Schuermans v1.0.3

Stefan Schuermans authored 13 years ago

34) #include <intern/strtod_noloc.h>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

35) #include <intern/types.h>
36) 
37) /**
38)  * \brief process distributor from config file
39)  *
40)  * \param[in,out] p_ctx context information
41)  * \param[in] p_setting_part2 second half of setting to process
42)  * \param[in] p_value value of setting
43)  * \return 0 in case of success, -1 in case of error
44)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

45) int etp_config_proc_distri(etp_config_ctx_t *p_ctx, char *p_setting_part2,
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

46)                            char *p_value)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

47) {
48)   char *ptr;
49)   unsigned long val;
50)   unsigned int distri, out, pix, i;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

51)   etp_distri_t *p_distri;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

52) 
53)   /* get distributor number */
54)   val = strtoul(p_setting_part2, &ptr, 0);
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

55)   if (ptr == p_setting_part2 || *ptr != 0 || val >= ETP_DISTRI_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

56)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

57)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

58)                         "invalid distributor number \"%s\""
59)                         " in line %u of config file\n",
60)                         p_setting_part2, p_ctx->line_no);
61)     return -1;
62)   }
63)   distri = (unsigned int)val;
64) 
65)   /* get number of outputs and pixels */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

66)   if (etp_parse_two_nos(p_value, &out, &pix, &ptr) || *ptr != 0) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

67)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

68)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

69)                         "invalid distributor size \"%s\""
70)                         " in line %u of config file\n",
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

71)                         p_value, p_ctx->line_no);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

72)     return -1;
73)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

74)   if (out >= ETP_OUTPUT_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

75)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

76)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

77)                         "invalid number of outputs \"%u\""
78)                         " in line %u of config file\n",
79)                         out, p_ctx->line_no);
80)     return -1;
81)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

82)   if (pix >= ETP_PIXEL_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

83)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

84)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

85)                         "invalid number of pixels \"%u\""
86)                         " in line %u of config file\n",
87)                         pix, p_ctx->line_no);
88)     return -1;
89)   }
90) 
91)   /* check if distributor is already present */
92)   if (p_ctx->p_display->distri_ptrs[distri]) {
93)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

94)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

95)                         "duplicate definition of distributor \"%u\""
96)                         " in line %u of config file\n",
97)                         distri, p_ctx->line_no);
98)     return -1;
99)   }
100) 
101)   /* create a new distributor */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

102)   p_distri = (etp_distri_t *)malloc(sizeof (etp_distri_t));
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

103)   if (!p_distri) {
104)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

105)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err, "out of memory\n");
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

106)     return -1;
107)   }
108)   p_distri->distri = distri;
109)   p_distri->output_cnt = out;
110)   p_distri->pixel_cnt = pix;
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

111)   /* initialize address to default */
112)   p_distri->addr.sin_family = AF_INET;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

113)   p_distri->addr.sin_addr.s_addr = htonl(ETP_DEST_IP_BASE +
114)                                          p_distri->distri * ETP_DEST_IP_STEP);
115)   p_distri->addr.sin_port = htons(ETP_DEST_PORT);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

116)   /* initialize mapping information */
117)   for (i = 0; i < 3; i++) {
118)     p_distri->mapping[i].base = 0.0;
119)     p_distri->mapping[i].gamma = 1.0;
120)     p_distri->mapping[i].factor = 1.0;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

121)     etp_mapping_precalc(&p_distri->mapping[i]);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

122)   }
123)   /* create and initialize pixel array */
124)   p_distri->p_pixels =
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

125)     (etp_pixel_t *)malloc(out * pix * sizeof (etp_pixel_t));
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

126)   if (!p_distri->p_pixels) {
127)     free(p_distri);
128)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

129)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err, "out of memory\n");
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

130)     return -1;
131)   }
132)   for (i = 0; i < out * pix; i++) {
133)     p_distri->p_pixels[i].x = -1;
134)     p_distri->p_pixels[i].y = -1;
135)   }
136)   /* create and initialize message buffer */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

137)   p_distri->msg_len = ETP_MCUF_HDR_LEN + out * pix * 3;
138)   p_distri->p_msg_buf = (etp_u8_t *)malloc(p_distri->msg_len);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

139)   if (!p_distri->p_msg_buf) {
140)     free(p_distri->p_pixels);
141)     free(p_distri);
142)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

143)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err, "out of memory\n");
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

144)     return -1;
145)   }
146)   memset(p_distri->p_msg_buf, 0, p_distri->msg_len);
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

147)   memcpy(p_distri->p_msg_buf, etp_mcuf_hdr, ETP_MCUF_HDR_LEN);
Stefan Schuermans support more pixels per output

Stefan Schuermans authored 7 years ago

148)   p_distri->p_msg_buf[ETP_MCUF_HDR_OFS_OUTPUTS_U16 + 0] = (etp_u8_t)(out >> 8);
149)   p_distri->p_msg_buf[ETP_MCUF_HDR_OFS_OUTPUTS_U16 + 1] = (etp_u8_t)out;
150)   p_distri->p_msg_buf[ETP_MCUF_HDR_OFS_PIXELS_U16 + 0] = (etp_u8_t)(pix >> 8);
151)   p_distri->p_msg_buf[ETP_MCUF_HDR_OFS_PIXELS_U16 + 1] = (etp_u8_t)pix;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

152)   /* store pointer to distributor */
153)   p_ctx->p_display->distri_ptrs[distri] = p_distri;
154) 
155)   /* count distributors */
156)   p_ctx->p_display->distri_cnt++;
157) 
158)   return 0;
159) }
160) 
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

161) /**
162)  * \brief process distributor address from config file
163)  *
164)  * \param[in,out] p_ctx context information
165)  * \param[in] p_setting_part2 second half of setting to process
166)  * \param[in] p_value value of setting
167)  * \return 0 in case of success, -1 in case of error
168)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

169) int etp_config_proc_distri_addr(etp_config_ctx_t *p_ctx, char *p_setting_part2,
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

170)                                 char *p_value)
171) {
172)   char *ptr;
173)   unsigned long val;
174)   unsigned int distri;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

175)   etp_distri_t *p_distri;
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

176) 
177)   /* get distributor number */
178)   val = strtoul(p_setting_part2, &ptr, 0);
Stefan Schuermans stricter parsing for distri...

Stefan Schuermans authored 7 years ago

179)   if (ptr == p_setting_part2 || *ptr != 0) {
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

180)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

181)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

182)                         "invalid mapping specifier \"%s\""
183)                         " in line %u of config file\n",
184)                         p_setting_part2, p_ctx->line_no);
185)     return -1;
186)   }
187)   distri = (unsigned int)val;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

188)   if (distri >= ETP_DISTRI_MAX_CNT) {
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

189)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

190)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

191)                         "invalid distributor number \"%u\""
192)                         " in line %u of config file\n",
193)                         distri, p_ctx->line_no);
194)     return -1;
195)   }
196) 
197)   /* get distributor */
198)   p_distri = p_ctx->p_display->distri_ptrs[distri];
199)   if (!p_distri) {
200)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

201)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

202)                         "no distributor with number \"%u\""
203)                         " in line %u of config file\n",
204)                         distri, p_ctx->line_no);
205)     return -1;
206)   }
207) 
208)   /* get address */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

209)   if (etp_parse_addr(p_value, &p_distri->addr)) {
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

210)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

211)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

212)                         "invalid address \"%s\" for distributor with number"
213)                         " \"%u\" in line %u of config file\n",
214)                         p_value, distri, p_ctx->line_no);
215)     return -1;
216)   }
217) 
218)   return 0;
219) }
220) 
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

221) /**
222)  * \brief process mapping from config file
223)  *
224)  * \param[in,out] p_ctx context information
225)  * \param[in] p_setting_part2 second half of setting to process
226)  * \param[in] p_value value of setting
227)  * \return 0 in case of success, -1 in case of error
228)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

229) int etp_config_proc_mapping(etp_config_ctx_t *p_ctx, char *p_setting_part2,
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

230)                             char *p_value)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

231) {
232)   char *ptr, *ptr2;
233)   unsigned long val;
234)   unsigned int distri, chan;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

235)   etp_distri_t *p_distri;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

236)   double base, factor, gamma;
237) 
238)   /* get distributor number */
239)   val = strtoul(p_setting_part2, &ptr, 0);
240)   if (ptr == p_setting_part2
241)       || (*ptr != 0 && *ptr != ' ' && *ptr != '\t'
242)           && *ptr != '\r' && *ptr != '\n')) {
243)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

244)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

245)                         "invalid mapping specifier \"%s\""
246)                         " in line %u of config file\n",
247)                         p_setting_part2, p_ctx->line_no);
248)     return -1;
249)   }
250)   distri = (unsigned int)val;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

251)   if (distri >= ETP_DISTRI_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

252)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

253)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

254)                         "invalid distributor number \"%u\""
255)                         " in line %u of config file\n",
256)                         distri, p_ctx->line_no);
257)     return -1;
258)   }
259) 
260)   /* get channel */
261)   while (*ptr == ' ' || *ptr == '\t' || *ptr == '\r' || *ptr == '\n')
262)     ptr++;
263)   if (!strcmp(ptr, "red"))
264)     chan = 0;
265)   else if (!strcmp(ptr, "green"))
266)     chan = 1;
267)   else if (!strcmp(ptr, "blue"))
268)     chan = 2;
269)   else {
270)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

271)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

272)                         "invalid channel \"%s\""
273)                         " in line %u of config file\n", ptr,
274)                         p_ctx->line_no);
275)     return -1;
276)   }
277) 
278)   /* get distributor */
279)   p_distri = p_ctx->p_display->distri_ptrs[distri];
280)   if (!p_distri) {
281)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

282)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

283)                         "no distributor with number \"%u\""
284)                         " in line %u of config file\n",
285)                         distri, p_ctx->line_no);
286)     return -1;
287)   }
288) 
289)   /* get mapping parameters: base, factor, gamma */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

290)   base = etp_strtod_noloc(p_value, &ptr);
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

291)   if (ptr == p_value
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

292)       || (*ptr != 0 && *ptr != ' ' && *ptr != '\t'
293)           && *ptr != '\r' && *ptr != '\n')) {
294)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

295)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

296)                         "invalid mapping parameters \"%s\""
297)                         " in line %u of config file\n",
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

298)                         p_value, p_ctx->line_no);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

299)     return -1;
300)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

301)   factor = etp_strtod_noloc(ptr, &ptr2);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

302)   if (ptr2 == ptr
303)       || (*ptr2 != 0 && *ptr2 != ' ' && *ptr2 != '\t'
304)           && *ptr2 != '\r' && *ptr2 != '\n')) {
305)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

306)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

307)                         "invalid mapping parameters \"%s\""
308)                         " in line %u of config file\n",
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

309)                         p_value, p_ctx->line_no);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

310)     return -1;
311)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

312)   gamma = etp_strtod_noloc(ptr2, &ptr);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

313)   if (ptr == ptr2
314)       || (*ptr != 0 && *ptr != ' ' && *ptr != '\t'
315)           && *ptr != '\r' && *ptr != '\n')) {
316)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

317)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

318)                         "invalid mapping parameters \"%s\""
319)                         " in line %u of config file\n",
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

320)                         p_value, p_ctx->line_no);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

321)     return -1;
322)   }
323)   if (gamma <= 0.0) {
324)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

325)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

326)                         "invalid gamma value \"%f\""
327)                         " in line %u of config file\n",
328)                         gamma, p_ctx->line_no);
329)     return -1;
330)   }
331) 
332)   /* store new mapping parameters and re-calculate mapping table */
333)   p_distri->mapping[chan].base = base;
334)   p_distri->mapping[chan].factor = factor;
335)   p_distri->mapping[chan].gamma = gamma;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

336)   etp_mapping_precalc(&p_distri->mapping[chan]);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

337) 
338)   return 0;
339) }
340) 
341) /**
342)  * \brief process pixel from config file
343)  *
344)  * \param[in,out] p_ctx context information
345)  * \param[in] sz_pixel text of pixel to process
346)  * \param[in] distri number of distributor
347)  * \param[in] out number of output
348)  * \param[in] pix number of pixel
349)  * \return 0 in case of success, -1 in case of error
350)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

351) int etp_config_proc_pixel(etp_config_ctx_t *p_ctx, char *sz_pixel,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

352)                           unsigned int distri, unsigned int out,
353)                           unsigned int pix)
354) {
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

355)   etp_distri_t *p_distri = p_ctx->p_display->distri_ptrs[distri];
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

356)   char *ptr;
357)   unsigned int x, y, idx;
358) 
359)   /* get coordinates of pixel */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

360)   if (etp_parse_two_nos(sz_pixel, &x, &y, &ptr) || *ptr != 0
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

361)       || (int)x < 0 || (int)x >= p_ctx->p_display->size.x
362)       || (int)y < 0 || (int)y >= p_ctx->p_display->size.y) {
363)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

364)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

365)                         "invalid pixel \"%s\""
366)                         " in line %u of config file\n",
367)                         sz_pixel, p_ctx->line_no);
368)     return -1;
369)   }
370) 
371)   /* check pixel number */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

372)   if (pix >= ETP_PIXEL_MAX_CNT || pix >= p_distri->pixel_cnt) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

373)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

374)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

375)                         "too many pixels (more than %u)"
376)                         " in line %u of config file\n",
377)                         p_distri->pixel_cnt, p_ctx->line_no);
378)     return -1;
379)   }
380) 
381)   /* check that pixel is not yet set */
382)   idx = out * p_distri->pixel_cnt + pix;
383)   if (p_distri->p_pixels[idx].x >= 0
384)       && p_distri->p_pixels[idx].y >= 0) {
385)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

386)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

387)                         "pixel %u of output %u of distributor %u already set"
388)                         " to pixel %u,%u in line %u of config file\n",
389)                         pix, out, distri, p_distri->p_pixels[idx].x,
390)                  p_distri->p_pixels[idx].y, p_ctx->line_no);
391)     return -1;
392)   }
393) 
394)   /* set pixel coordinates */
395)   p_distri->p_pixels[idx].x = x;
396)   p_distri->p_pixels[idx].y = y;
397) 
398)   /* count pixels in total */
399)   p_ctx->p_display->pixel_cnt++;
400) 
401)   return 0;
402) }
403) 
404) /**
405)  * \brief process output from config file
406)  *
407)  * \param[in,out] p_ctx context information
408)  * \param[in] p_setting_part2 second half of setting to process
409)  * \param[in] p_value value of setting
410)  * \return 0 in case of success, -1 in case of error
411)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

412) int etp_config_proc_output(etp_config_ctx_t *p_ctx, char *p_setting_part2,
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

413)                            char *p_value)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

414) {
415)   char *ptr, *p_pos, *p_white, white;
416)   unsigned int distri, out, pix;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

417)   etp_distri_t *p_distri;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

418)   int err;
419) 
420)   /* get number of distributor and output */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

421)   if (etp_parse_two_nos(p_setting_part2, &distri, &out, &ptr) || *ptr != 0) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

422)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

423)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

424)                         "invalid output specifier \"%s\""
425)                         " in line %u of config file\n",
426)                         p_setting_part2, p_ctx->line_no);
427)     return -1;
428)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

429)   if (distri >= ETP_DISTRI_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

430)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

431)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

432)                         "invalid distributor number \"%u\""
433)                         " in line %u of config file\n",
434)                         distri, p_ctx->line_no);
435)     return -1;
436)   }
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

437)   if (out >= ETP_OUTPUT_MAX_CNT) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

438)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

439)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

440)                         "invalid output number \"%u\""
441)                         " in line %u of config file\n",
442)                         out, p_ctx->line_no);
443)     return -1;
444)   }
445) 
446)   /* get distributor */
447)   p_distri = p_ctx->p_display->distri_ptrs[distri];
448)   if (!p_distri) {
449)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

450)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

451)                         "no distributor with number \"%u\""
452)                         " in line %u of config file\n",
453)                         distri, p_ctx->line_no);
454)     return -1;
455)   }
456)   /* check output number */
457)   if (out >= p_distri->output_cnt) {
458)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

459)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

460)                         "no output with output number \"%u\""
461)                         " in line %u of config file\n",
462)                         out, p_ctx->line_no);
463)     return -1;
464)   }
465) 
466)   /* count outputs */
467)   p_ctx->p_display->output_cnt++;
468) 
469)   /* process pixels */
470) 
471)   /* process all parts separated by whitespace */
Stefan Schuermans value -> p_value for consis...

Stefan Schuermans authored 7 years ago

472)   p_pos = p_value;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

473)   err = 0;
474)   pix = 0;
475)   while (*p_pos != 0) {
476) 
477)     /* get end of item (first whitespace) */
478)     for (p_white = p_pos;
479)          *p_white && *p_white != ' ' && *p_white != '\t'
480)          && *p_white != '\r' && *p_white != '\n'; p_white++);
481) 
482)     /* process item: a pixel */
483)     white = *p_white; /* terminate item */
484)     *p_white = 0;
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

485)     if (etp_config_proc_pixel(p_ctx, p_pos, distri, out, pix)) /* process */
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

486)       err = -1;       /* remember errors */
487)     pix++;            /* count pixels */
488)     *p_white = white; /* undo termination */
489) 
490)     /* skip whitespace and continue after it */
491)     for (;
492)          *p_white == ' ' || *p_white == '\t'
493)          || *p_white == '\r' || *p_white == '\n'; p_white++);
494)     p_pos = p_white;
495) 
496)   } /* while (*p_pos != 0) */
497) 
498)   return err;
499) }
500) 
501) /**
502)  * \brief process setting from config file
503)  *
504)  * \param[in,out] p_ctx context information
505)  * \param[in] p_setting setting to process
506)  * \param[in] p_value value of setting
507)  * \return 0 in case of success, -1 in case of error
508)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

509) int etp_config_proc_setting(etp_config_ctx_t *p_ctx, char *p_setting,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

510)                             char *p_value)
511) {
512)   char *ptr;
513)   unsigned int x, y;
514) 
515)   /* replace all whitespace with spaces in setting */
516)   while ((ptr = strchr(p_setting, '\t')))
517)     *ptr = ' ';
518)   while ((ptr = strchr(p_setting, '\r')))
519)     *ptr = ' ';
520)   while ((ptr = strchr(p_setting, '\n')))
521)     *ptr = ' ';
522) 
523)   /* bind address for UDP output */
524)   if (!strcmp(p_setting, "bindAddr")) {
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

525)     if (etp_parse_addr(p_value, &p_ctx->p_display->bind_addr)) {
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

526)       if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

527)         p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

528)                           "invalid address \"%s\" for \"%s\""
529)                           " in line %u of config file\n",
530)                           p_value, p_setting, p_ctx->line_no);
531)       return -1;
532)     }
533)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

534)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_info, "bind address: %s\n", p_value);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

535)     return 0;
536)   }
537) 
538)   /* size of display */
539)   if (!strcmp(p_setting, "size")) {
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

540)     if (etp_parse_two_nos(p_value, &x, &y, &ptr)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

541)         || (int)x <= 0 || (int)y <= 0) {
542)       if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

543)         p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

544)                           "invalid value \"%s\" for \"%s\""
545)                           " in line %u of config file\n",
546)                           p_value, p_setting, p_ctx->line_no);
547)       return -1;
548)     }
549)     p_ctx->p_display->size.x = x;
550)     p_ctx->p_display->size.y = y;
551)     return 0;
552)   }
553) 
554)   /* distributor */
555)   if (!strncmp(p_setting, "distributor ", 12))
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

556)     return etp_config_proc_distri(p_ctx, p_setting + 12, p_value);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

557) 
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

558)   /* distributor address */
559)   if (!strncmp(p_setting, "distributorAddr ", 16))
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

560)     return etp_config_proc_distri_addr(p_ctx, p_setting + 16, p_value);
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

561) 
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

562)   /* mapping */
563)   if (!strncmp(p_setting, "mapping ", 8))
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

564)     return etp_config_proc_mapping(p_ctx, p_setting + 8, p_value);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

565) 
566)   /* output */
567)   if (!strncmp(p_setting, "output ", 7))
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

568)     return etp_config_proc_output(p_ctx, p_setting + 7, p_value);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

569) 
570)   /* unknown setting */
571)   if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

572)     p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_warn,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

573)                       "unknown setting \"%s\""
574)                       " in line %u of config file, ignored\n",
575)                       p_setting, p_ctx->line_no);
576)   return 0;
577) }
578) 
579) /**
580)  * \brief process line from config file
581)  *
582)  * \param[in,out] p_ctx context information
583)  * \param[in] p_line line to process
584)  * \return 0 in case of success, -1 in case of error
585)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

586) int etp_config_proc_line(etp_config_ctx_t *p_ctx, char *p_line)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

587) {
588)   char *p_hash, *p_equal, *p_setting, *p_value;
589)   int i;
590) 
591)   /* remove comment */
592)   p_hash = strchr(p_line, '#');
593)   if (p_hash)
594)     *p_hash = 0;
595) 
596)   /* remove trailing whitespace */
597)   for (i = strlen(p_line) - 1;
598)        i >= 0 && (p_line[i] == ' ' || p_line[i] == '\t'
599)                   || p_line[i] == '\r' || p_line[i] == '\n'); i--)
600)     p_line[i] = 0;
601) 
602)   /* remove leading whitespace */
603)   for (; *p_line == ' ' || *p_line == '\t'
604)          || *p_line == '\r' || *p_line == '\n'; p_line++);
605) 
606)   /* ignore empty line */
607)   if (!p_line[0])
608)     return 0;
609) 
610)   /* find equal sign */
611)   p_equal = strchr(p_line, '=');
612)   if (!p_equal) {               /* no equal sign found */
613)     if (p_ctx->p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

614)       p_ctx->p_msg_func(p_ctx->p_msg_ctx, etp_msg_type_warn,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

615)                         "invalid line %u in config file, ignored\n",
616)                         p_ctx->line_no);
617)     return 0;
618)   }
619) 
620)   /* split string at equal sign */
621)   *p_equal = 0;
622)   p_setting = p_line;
623)   p_value = p_equal + 1;
624) 
625)   /* remove trailing whitespaces in setting name */
626)   for (i = strlen(p_setting) - 1;
627)        i >= 0 && (p_setting[i] == ' ' || p_setting[i] == '\t'
628)                   || p_setting[i] == '\r' || p_setting[i] == '\n'); i--)
629)     p_setting[i] = 0;
630) 
631)   /* remove leading whitespaces in value */
632)   for (; *p_value == ' ' || *p_value == '\t'
633)          || *p_value == '\r' || *p_value == '\n'; p_value++);
634) 
635)   /* process setting */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

636)   return etp_config_proc_setting(p_ctx, p_setting, p_value);
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

637) }
638) 
639) /**
640)  * \brief process config file
641)  *
642)  * \param[in,out] p_display display to configure
643)  * \param[in] sz_config_file name of config file to read
644)  * \param[in] p_msg_func message callback function or NULL
645)  * \param[in] p_msg_ctx user context for message callback
646)  * \return 0 in case of success, -1 in case of error
647)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

648) int etp_config_proc_file(etp_display_t *p_display,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

649)                          const char *sz_config_file,
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

650)                          etp_msg_func_p_t p_msg_func, void *p_msg_ctx)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

651) {
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

652)   etp_config_ctx_t ctx;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

653)   FILE *file;
654) 
655)   /* set up context */
656)   ctx.p_display = p_display;
657)   ctx.p_msg_func = p_msg_func;
658)   ctx.p_msg_ctx = p_msg_ctx;
659) 
660)   /* check if file is present */
661)   if (!sz_config_file || !sz_config_file[0]) {
662)     if (p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

663)       p_msg_func(p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

664)                  "no config file specified\n");
665)     return -1;
666)   }
667) 
668)   if (p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

669)     p_msg_func(p_msg_ctx, etp_msg_type_info,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

670)                "using config file \"%s\"\n",
671)                sz_config_file);
672) 
673)   /* open file */
674)   file = fopen(sz_config_file, "rt");
675)   if (!file) {
Stefan Schuermans v1.0.2

Stefan Schuermans authored 13 years ago

676)     if (p_msg_func) {
677)       char errmsg[256];
678)       strerror_r(errno, errmsg, sizeof(errmsg));
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

679)       p_msg_func(p_msg_ctx, etp_msg_type_err,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

680)                  "cannot open config file \"%s\" for reading: %s\n",
Stefan Schuermans v1.0.2

Stefan Schuermans authored 13 years ago

681)                  sz_config_file, errmsg);
682)     }
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

683)     return -1;
684)   }
685) 
686)   /* process lines in file */
687)   ctx.line_no = 1;
688)   while (!feof(file)) {
689)     char line[4096], *p_lf;
690) 
691)     /* read a line */
692)     line[0] = 0;
Stefan Schuermans adaptions for gcc 5

Stefan Schuermans authored 7 years ago

693)     if (fgets(line, sizeof (line), file) == NULL)
694)       break;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

695)     p_lf = strchr(line, '\n'); /* find LF in line in replace it with 0 */
696)     if (p_lf)
697)       *p_lf = 0;
698)     else {                     /* no LF in line */
699)       if (!feof(file)) {       /* not at end of file */
700)         char dummy[4096];
701)         if (p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

702)           p_msg_func(p_msg_ctx, etp_msg_type_warn,
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

703)                      "line %u too long in config file, truncated\n",
704)                      ctx.line_no);
705)         /* jump over in rest of line */
706)         dummy[0] = 0;
707)         while (!feof(file) && !strchr(dummy, '\n'))
Stefan Schuermans adaptions for gcc 5

Stefan Schuermans authored 7 years ago

708)           if (fgets(dummy, sizeof (dummy), file) == NULL)
709)             break;
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

710)       }
711)     }
712) 
713)     /* process line from file */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

714)     if (etp_config_proc_line(&ctx, line))
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

715)       return -1;
716) 
717)     ctx.line_no++;
718)   }
719) 
720)   /* close file */
721)   fclose(file);
722) 
723)   if (p_msg_func)
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

724)     p_msg_func(p_msg_ctx, etp_msg_type_info,