Browse code

FIFO support for version added

Jiri Kuthan authored on 30/08/2002 22:10:50
Showing 2 changed files
... ...
@@ -425,6 +425,31 @@ int open_fifo_server()
425 425
 	return 1;
426 426
 }
427 427
 
428
+static int print_version_cmd( FILE *stream, char *response_file )
429
+{
430
+	int file;
431
+
432
+	if (response_file) {
433
+		file=open( response_file, O_WRONLY );
434
+		if (file<0) {
435
+			LOG(L_ERR, "ERROR: print_version_cmd: open error (%s): %s\n",
436
+				response_file, strerror(errno));
437
+			return -1;
438
+		}
439
+		if (write(file, SERVER_HDR CRLF, SERVER_HDR_LEN+CRLF_LEN)<0) {
440
+			LOG(L_ERR, "ERROR: print_version_cmd: write error: %s\n",
441
+				strerror(errno));
442
+			close(file);
443
+			return -1;
444
+		}
445
+		close(file);
446
+	} else {
447
+		LOG(L_ERR, "ERROR: no file for print_version_cmd\n");
448
+	}
449
+	return 1;
450
+}
451
+	
452
+
428 453
 /* diagnostic and hello-world FIFO command */
429 454
 static int print_fifo_cmd( FILE *stream, char *response_file )
430 455
 {
... ...
@@ -495,5 +520,9 @@ int register_core_fifo()
495 495
 		LOG(L_CRIT, "unable to register 'print' FIFO cmd\n");
496 496
 		return -1;
497 497
 	}
498
+	if (register_fifo_cmd(print_version_cmd, FIFO_VERSION, 0)<0) {
499
+		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
500
+		return -1;
501
+	}
498 502
 	return 1;
499 503
 }
... ...
@@ -13,6 +13,7 @@
13 13
 /* core FIFO command set */
14 14
 #define FIFO_PRINT "print"
15 15
 #define FIFO_UPTIME "uptime"
16
+#define FIFO_VERSION "version"
16 17
 
17 18
 typedef int (fifo_cmd)( FILE *fifo_stream, char *response_file );
18 19