... | ... |
@@ -255,6 +255,24 @@ static char *trim_filename( char * file ) |
255 | 255 |
return new_fn; |
256 | 256 |
} |
257 | 257 |
|
258 |
+/* tell FIFO client what happened via reply pipe */ |
|
259 |
+void fifo_reply( char *reply_fifo, char *reply_txt) |
|
260 |
+{ |
|
261 |
+ FILE *file_handle; |
|
262 |
+ |
|
263 |
+ file_handle=open_reply_pipe(reply_fifo); |
|
264 |
+ if (file_handle==0) { |
|
265 |
+ LOG(L_ERR, "ERROR: fifo_reply: no reply pipe %s\n", |
|
266 |
+ fifo); |
|
267 |
+ return; |
|
268 |
+ } |
|
269 |
+ if (fprintf(file_handle, "%s", reply_txt)<=0) { |
|
270 |
+ LOG(L_ERR, "ERROR: fifo_error: write error (%s): %s\n", |
|
271 |
+ fifo, strerror(errno)); |
|
272 |
+ } |
|
273 |
+ fclose(file_handle); |
|
274 |
+} |
|
275 |
+ |
|
258 | 276 |
FILE *open_reply_pipe( char *pipe_name ) |
259 | 277 |
{ |
260 | 278 |
FILE *file_handle; |
... | ... |
@@ -346,6 +364,7 @@ static void fifo_server(FILE *fifo_stream) |
346 | 364 |
if (f->f(fifo_stream, file)<0) { |
347 | 365 |
LOG(L_ERR, "ERROR: fifo_server: command (%s) " |
348 | 366 |
"processing failed\n", command ); |
367 |
+#ifdef _OBSOLETED |
|
349 | 368 |
file_handle=open_reply_pipe(file); |
350 | 369 |
if (file_handle==0) { |
351 | 370 |
LOG(L_ERR, "ERROR: fifo_server: no reply pipe\n"); |
... | ... |
@@ -356,6 +375,7 @@ static void fifo_server(FILE *fifo_stream) |
356 | 375 |
strerror(errno)); |
357 | 376 |
} |
358 | 377 |
fclose(file_handle); |
378 |
+#endif |
|
359 | 379 |
goto consume; |
360 | 380 |
} |
361 | 381 |
|
... | ... |
@@ -431,9 +451,9 @@ int open_fifo_server() |
431 | 451 |
|
432 | 452 |
static int print_version_cmd( FILE *stream, char *response_file ) |
433 | 453 |
{ |
434 |
- int file; |
|
435 |
- |
|
436 | 454 |
if (response_file) { |
455 |
+ fifo_reply(response_file, SERVER_HDR CRLF ); |
|
456 |
+#ifdef _OBSOLETED |
|
437 | 457 |
file=open( response_file, O_WRONLY ); |
438 | 458 |
if (file<0) { |
439 | 459 |
LOG(L_ERR, "ERROR: print_version_cmd: open error (%s): %s\n", |
... | ... |
@@ -447,6 +467,7 @@ static int print_version_cmd( FILE *stream, char *response_file ) |
447 | 467 |
return -1; |
448 | 468 |
} |
449 | 469 |
close(file); |
470 |
+#endif |
|
450 | 471 |
} else { |
451 | 472 |
LOG(L_ERR, "ERROR: no file for print_version_cmd\n"); |
452 | 473 |
} |
... | ... |
@@ -459,15 +480,24 @@ static int print_fifo_cmd( FILE *stream, char *response_file ) |
459 | 480 |
{ |
460 | 481 |
char text[MAX_PRINT_TEXT]; |
461 | 482 |
int text_len; |
462 |
- int file; |
|
463 | 483 |
|
464 | 484 |
/* expect one line which will be printed out */ |
485 |
+ if (response_file==0 || *response_file==0 ) { |
|
486 |
+ LOG(L_ERR, "ERROR: print_fifo_cmd: null file\n"); |
|
487 |
+ return -1; |
|
488 |
+ } |
|
465 | 489 |
if (!read_line(text, MAX_PRINT_TEXT, stream, &text_len)) { |
490 |
+#ifdef _OBSOLETED |
|
466 | 491 |
LOG(L_ERR, "ERROR: print_fifo_cmd: too big text\n"); |
492 |
+#endif |
|
493 |
+ fifo_reply(response_file, |
|
494 |
+ "ERROR: print_fifo_cmd: too big text"); |
|
467 | 495 |
return -1; |
468 | 496 |
} |
469 | 497 |
/* now the work begins */ |
470 | 498 |
if (response_file) { |
499 |
+ fifo_reply(response_file, text ); |
|
500 |
+#ifdef _OBSOLETED |
|
471 | 501 |
file=open( response_file , O_WRONLY); |
472 | 502 |
if (file<0) { |
473 | 503 |
LOG(L_ERR, "ERROR: print_fifo_cmd: open error (%s): %s\n", |
... | ... |
@@ -478,9 +508,10 @@ static int print_fifo_cmd( FILE *stream, char *response_file ) |
478 | 508 |
LOG(L_ERR, "ERROR: print_fifo_cmd: write error: %s\n", |
479 | 509 |
strerror(errno)); |
480 | 510 |
close(file); |
481 |
- return -1; |
|
511 |
+ return 1; |
|
482 | 512 |
} |
483 | 513 |
close(file); |
514 |
+#endif |
|
484 | 515 |
} else { |
485 | 516 |
LOG(L_INFO, "INFO: print_fifo_cmd: %.*s\n", |
486 | 517 |
text_len, text ); |
... | ... |
@@ -194,7 +194,7 @@ static void delete_cell( struct cell *p_cell, int unlock ) |
194 | 194 |
|
195 | 195 |
|
196 | 196 |
|
197 |
-inline void retransmission_handler( void *attr) |
|
197 |
+inline static void retransmission_handler( void *attr) |
|
198 | 198 |
{ |
199 | 199 |
struct retr_buf* r_buf ; |
200 | 200 |
enum lists id; |
... | ... |
@@ -234,7 +234,7 @@ inline void retransmission_handler( void *attr) |
234 | 234 |
|
235 | 235 |
|
236 | 236 |
|
237 |
-inline void final_response_handler( void *attr) |
|
237 |
+inline static void final_response_handler( void *attr) |
|
238 | 238 |
{ |
239 | 239 |
int silent; |
240 | 240 |
struct retr_buf* r_buf; |
... | ... |
@@ -358,7 +358,7 @@ void cleanup_localcancel_timers( struct cell *t ) |
358 | 358 |
} |
359 | 359 |
|
360 | 360 |
|
361 |
-inline void wait_handler( void *attr) |
|
361 |
+inline static void wait_handler( void *attr) |
|
362 | 362 |
{ |
363 | 363 |
struct cell *p_cell = (struct cell*)attr; |
364 | 364 |
|
... | ... |
@@ -391,7 +391,7 @@ inline void wait_handler( void *attr) |
391 | 391 |
|
392 | 392 |
|
393 | 393 |
|
394 |
-inline void delete_handler( void *attr) |
|
394 |
+inline static void delete_handler( void *attr) |
|
395 | 395 |
{ |
396 | 396 |
struct cell *p_cell = (struct cell*)attr; |
397 | 397 |
|
... | ... |
@@ -258,22 +258,30 @@ int fifo_uac( FILE *stream, char *response_file ) |
258 | 258 |
and proceed to a new request |
259 | 259 |
*/ |
260 | 260 |
LOG(L_ERR, "ERROR: fifo_uac: method expected\n"); |
261 |
+ fifo_reply(response_file, |
|
262 |
+ "ERROR: fifo_uac: method expected"); |
|
261 | 263 |
return -1; |
262 | 264 |
} |
263 | 265 |
DBG("DEBUG: fifo_uac: method: %.*s\n", sm.len, method ); |
264 | 266 |
if (!read_line(dst, MAX_DST, stream, &sd.len)||sd.len==0) { |
267 |
+ fifo_reply(response_file, |
|
268 |
+ "ERROR: fifo_uac: destination expected\n"); |
|
265 | 269 |
LOG(L_ERR, "ERROR: fifo_uac: destination expected\n"); |
266 | 270 |
return -1; |
267 | 271 |
} |
268 | 272 |
DBG("DEBUG: fifo_uac: dst: %.*s\n", sd.len, dst ); |
269 | 273 |
/* now read header fields line by line */ |
270 | 274 |
if (!read_line_set(header, MAX_HEADER, stream, &sh.len)) { |
275 |
+ fifo_reply(response_file, |
|
276 |
+ "ERROR: fifo_uac: HFs expected\n"); |
|
271 | 277 |
LOG(L_ERR, "ERROR: fifo_uac: header fields expected\n"); |
272 | 278 |
return -1; |
273 | 279 |
} |
274 | 280 |
DBG("DEBUG: fifo_uac: header: %.*s\n", sh.len, header ); |
275 | 281 |
/* and eventually body */ |
276 | 282 |
if (!read_body(body, MAX_BODY, stream, &sb.len)) { |
283 |
+ fifo_reply(response_file, |
|
284 |
+ "ERROR: fifo_uac: body expected\n"); |
|
277 | 285 |
LOG(L_ERR, "ERROR: fifo_uac: body expected\n"); |
278 | 286 |
return -1; |
279 | 287 |
} |