Sfoglia il codice sorgente

new 'which' FIFO command introduced

Jiri Kuthan 23 anni fa
parent
commit
114eaa41c7
2 ha cambiato i file con 31 aggiunte e 0 eliminazioni
  1. 30 0
      fifo_server.c
  2. 1 0
      fifo_server.h

+ 30 - 0
fifo_server.c

@@ -532,6 +532,32 @@ static int uptime_fifo_cmd( FILE *stream, char *response_file )
 	return 1;
 }
 
+static int which_fifo_cmd(FILE *stream, char *response_file )
+{
+	FILE *reply_pipe;
+	struct fifo_command *c;
+
+	if (response_file==0 || *response_file==0 ) {
+		 LOG(L_ERR, "ERROR: which_fifo_cmd: null file\n");
+		return -1;
+	}
+
+	reply_pipe=open_reply_pipe(response_file);
+	if (reply_pipe==NULL) {
+		LOG(L_ERR, "ERROR: opening reply pipe (%s) failed\n",
+			response_file );
+		return -1;
+	}
+	fputs( "------ Begin of registered FIFO commands -----------\n", reply_pipe);
+	for(c=cmd_list; c; c=c->next) {
+		fprintf( reply_pipe, "%s\n", c->name );
+	}
+	fputs( "------ End of registered FIFO commands -----------\n", reply_pipe);
+
+	fclose(reply_pipe);
+	return 1;
+}
+
 
 int register_core_fifo()
 {
@@ -547,5 +573,9 @@ int register_core_fifo()
 		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
 		return -1;
 	}
+	if (register_fifo_cmd(which_fifo_cmd, FIFO_WHICH, 0)<0) {
+		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
+		return -1;
+	}
 	return 1;
 }

+ 1 - 0
fifo_server.h

@@ -14,6 +14,7 @@
 #define FIFO_PRINT "print"
 #define FIFO_UPTIME "uptime"
 #define FIFO_VERSION "version"
+#define FIFO_WHICH "which"
 
 #define MAX_CTIME_LEN 128