浏览代码

FIFO support for version added

Jiri Kuthan 23 年之前
父节点
当前提交
3165311a31
共有 2 个文件被更改,包括 30 次插入0 次删除
  1. 29 0
      fifo_server.c
  2. 1 0
      fifo_server.h

+ 29 - 0
fifo_server.c

@@ -425,6 +425,31 @@ int open_fifo_server()
 	return 1;
 	return 1;
 }
 }
 
 
+static int print_version_cmd( FILE *stream, char *response_file )
+{
+	int file;
+
+	if (response_file) {
+		file=open( response_file, O_WRONLY );
+		if (file<0) {
+			LOG(L_ERR, "ERROR: print_version_cmd: open error (%s): %s\n",
+				response_file, strerror(errno));
+			return -1;
+		}
+		if (write(file, SERVER_HDR CRLF, SERVER_HDR_LEN+CRLF_LEN)<0) {
+			LOG(L_ERR, "ERROR: print_version_cmd: write error: %s\n",
+				strerror(errno));
+			close(file);
+			return -1;
+		}
+		close(file);
+	} else {
+		LOG(L_ERR, "ERROR: no file for print_version_cmd\n");
+	}
+	return 1;
+}
+	
+
 /* diagnostic and hello-world FIFO command */
 /* diagnostic and hello-world FIFO command */
 static int print_fifo_cmd( FILE *stream, char *response_file )
 static int print_fifo_cmd( FILE *stream, char *response_file )
 {
 {
@@ -495,5 +520,9 @@ int register_core_fifo()
 		LOG(L_CRIT, "unable to register 'print' FIFO cmd\n");
 		LOG(L_CRIT, "unable to register 'print' FIFO cmd\n");
 		return -1;
 		return -1;
 	}
 	}
+	if (register_fifo_cmd(print_version_cmd, FIFO_VERSION, 0)<0) {
+		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
+		return -1;
+	}
 	return 1;
 	return 1;
 }
 }

+ 1 - 0
fifo_server.h

@@ -13,6 +13,7 @@
 /* core FIFO command set */
 /* core FIFO command set */
 #define FIFO_PRINT "print"
 #define FIFO_PRINT "print"
 #define FIFO_UPTIME "uptime"
 #define FIFO_UPTIME "uptime"
+#define FIFO_VERSION "version"
 
 
 typedef int (fifo_cmd)( FILE *fifo_stream, char *response_file );
 typedef int (fifo_cmd)( FILE *fifo_stream, char *response_file );