Browse code

new 'which' FIFO command introduced

Jiri Kuthan authored on 08/09/2002 15:41:06
Showing 2 changed files
... ...
@@ -532,6 +532,32 @@ static int uptime_fifo_cmd( FILE *stream, char *response_file )
532 532
 	return 1;
533 533
 }
534 534
 
535
+static int which_fifo_cmd(FILE *stream, char *response_file )
536
+{
537
+	FILE *reply_pipe;
538
+	struct fifo_command *c;
539
+
540
+	if (response_file==0 || *response_file==0 ) {
541
+		 LOG(L_ERR, "ERROR: which_fifo_cmd: null file\n");
542
+		return -1;
543
+	}
544
+
545
+	reply_pipe=open_reply_pipe(response_file);
546
+	if (reply_pipe==NULL) {
547
+		LOG(L_ERR, "ERROR: opening reply pipe (%s) failed\n",
548
+			response_file );
549
+		return -1;
550
+	}
551
+	fputs( "------ Begin of registered FIFO commands -----------\n", reply_pipe);
552
+	for(c=cmd_list; c; c=c->next) {
553
+		fprintf( reply_pipe, "%s\n", c->name );
554
+	}
555
+	fputs( "------ End of registered FIFO commands -----------\n", reply_pipe);
556
+
557
+	fclose(reply_pipe);
558
+	return 1;
559
+}
560
+
535 561
 
536 562
 int register_core_fifo()
537 563
 {
... ...
@@ -547,5 +573,9 @@ int register_core_fifo()
547 573
 		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
548 574
 		return -1;
549 575
 	}
576
+	if (register_fifo_cmd(which_fifo_cmd, FIFO_WHICH, 0)<0) {
577
+		LOG(L_CRIT, "unable to register 'version' FIFO cmd\n");
578
+		return -1;
579
+	}
550 580
 	return 1;
551 581
 }
... ...
@@ -14,6 +14,7 @@
14 14
 #define FIFO_PRINT "print"
15 15
 #define FIFO_UPTIME "uptime"
16 16
 #define FIFO_VERSION "version"
17
+#define FIFO_WHICH "which"
17 18
 
18 19
 #define MAX_CTIME_LEN 128
19 20