@@ -30,7 +30,7 @@ static wolfsentry_errcode_t test_action(
3030 (void )route_table ;
3131 (void )action_results ;
3232
33- /*printf( "action callback: a=\"%s\" parent_event=\"%s\" trigger=\"%s\" t=%u r_id=%u caller_arg=%p\n",
33+ /*fprintf(stderr, "action callback: a=\"%s\" parent_event=\"%s\" trigger=\"%s\" t=%u r_id=%u caller_arg=%p\n",
3434 wolfsentry_action_get_label(action),
3535 wolfsentry_event_get_label(parent_event),
3636 wolfsentry_event_get_label(trigger_event),
@@ -52,8 +52,7 @@ int sentry_init()
5252 if (ret < 0 ) {
5353 fprintf (stderr , "wolfsentry_init() returned " WOLFSENTRY_ERROR_FMT "\n" ,
5454 WOLFSENTRY_ERROR_FMT_ARGS (ret ));
55- printf ("unable to initialize wolfSentry" );
56- fflush (stdout );
55+ fprintf (stderr , "unable to initialize wolfSentry" );
5756 }
5857
5958 /* Insert the possible actions into wolfSentry */
@@ -119,8 +118,7 @@ int sentry_init()
119118
120119 if (f == NULL ) {
121120 fprintf (stderr , "fopen(%s): %s\n" ,wolfsentry_config_path ,strerror (errno ));
122- printf ("unable to open wolfSentry config file" );
123- fflush (stdout );
121+ fprintf (stderr , "unable to open wolfSentry config file" );
124122 }
125123
126124 /* Initalize the wolfSentry JSON parser */
@@ -131,26 +129,23 @@ int sentry_init()
131129 fprintf (stderr , "wolfsentry_config_json_init() returned "
132130 WOLFSENTRY_ERROR_FMT "\n" ,
133131 WOLFSENTRY_ERROR_FMT_ARGS (ret ));
134- printf ("error while initializing wolfSentry config parser" );
135- fflush (stdout );
132+ fprintf (stderr , "error while initializing wolfSentry config parser" );
136133 }
137134
138135 /* wolfSentry uses a streaming reader/parser for the config file */
139136 for (;;) {
140137 /* Read some data from the config file */
141138 size_t n = fread (buf , 1 , sizeof buf , f );
142139 if ((n < sizeof buf ) && ferror (f )) {
143- fprintf (stderr ,"fread(%s): %s\n" ,wolfsentry_config_path , strerror (errno ));
144- printf ("error while reading wolfSentry config file" );
145- fflush (stdout );
140+ fprintf (stderr , "fread(%s): %s\n" ,wolfsentry_config_path , strerror (errno ));
141+ fprintf (stderr , "error while reading wolfSentry config file" );
146142 }
147143
148144 /* Send the read data into the JSON parser */
149145 ret = wolfsentry_config_json_feed (jps , buf , n , err_buf , sizeof err_buf );
150146 if (ret < 0 ) {
151147 fprintf (stderr , "%.*s\n" , (int )sizeof err_buf , err_buf );
152- printf ("error while loading wolfSentry config file" );
153- fflush (stdout );
148+ fprintf (stderr , "error while loading wolfSentry config file" );
154149 }
155150 if ((n < sizeof buf ) && feof (f ))
156151 break ;
@@ -160,8 +155,7 @@ int sentry_init()
160155 /* Clean up the JSON parser */
161156 if ((ret = wolfsentry_config_json_fini (& jps , err_buf , sizeof err_buf )) < 0 ) {
162157 fprintf (stderr , "%.*s\n" , (int )sizeof err_buf , err_buf );
163- printf ("error while loading wolfSentry config file" );
164- fflush (stdout );
158+ fprintf (stderr , "error while loading wolfSentry config file" );
165159 }
166160
167161 return 0 ;
@@ -225,9 +219,8 @@ int sentry_action(ip_addr_t *local_ip, ip_addr_t *remote_ip, in_port_t local_por
225219 NULL ,
226220 & action_results );
227221
228- printf ( "TCP Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
222+ fprintf ( stderr , "TCP Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
229223 WOLFSENTRY_ERROR_FMT_ARGS (ret ));
230- fflush (stdout );
231224
232225 /* Check the result, if it contains "reject" then notify the caller */
233226 if (WOLFSENTRY_ERROR_DECODE_ERROR_CODE (ret ) >= 0 ) {
@@ -270,9 +263,8 @@ int sentry_action_ping(const ip_addr_t *addr, u8_t type)
270263 NULL ,
271264 NULL ,
272265 & action_results );
273- printf ( "PING Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
266+ fprintf ( stderr , "PING Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
274267 WOLFSENTRY_ERROR_FMT_ARGS (ret ));
275- fflush (stdout );
276268 if (WOLFSENTRY_ERROR_DECODE_ERROR_CODE (ret ) >= 0 ) {
277269 if (WOLFSENTRY_MASKIN_BITS (action_results , WOLFSENTRY_ACTION_RES_REJECT )) {
278270 return -1 ;
@@ -312,9 +304,8 @@ int sentry_action_mac(struct eth_addr *addr)
312304 NULL ,
313305 & action_results );
314306
315- printf ( "MAC Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
307+ fprintf ( stderr , "MAC Sentry action returned " WOLFSENTRY_ERROR_FMT "\n" ,
316308 WOLFSENTRY_ERROR_FMT_ARGS (ret ));
317- fflush (stdout );
318309 if (WOLFSENTRY_ERROR_DECODE_ERROR_CODE (ret ) >= 0 ) {
319310 if (WOLFSENTRY_MASKIN_BITS (action_results , WOLFSENTRY_ACTION_RES_REJECT )) {
320311 return -1 ;
0 commit comments