aboutsummaryrefslogtreecommitdiffstats
path: root/src/ftcat.c
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-12-09 12:45:44 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-12-09 12:45:44 -0500
commitce2538d74ca5b9650ca6d18203032e47edd36c60 (patch)
tree7ea79ab8ad03afa74210e2f9d7e352a81259c297 /src/ftcat.c
parenta1842e14f55a3230ae076aada09b56e6d6096b47 (diff)
timestamp.h: rip out old unneeded definitions
Diffstat (limited to 'src/ftcat.c')
-rw-r--r--src/ftcat.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ftcat.c b/src/ftcat.c
index 28f1924..f0a1c5f 100644
--- a/src/ftcat.c
+++ b/src/ftcat.c
@@ -21,6 +21,8 @@
21#include <string.h> 21#include <string.h>
22#include <signal.h> 22#include <signal.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h>
25#include <errno.h>
24 26
25#include "timestamp.h" 27#include "timestamp.h"
26 28
@@ -44,14 +46,16 @@ static int disable_all(int fd)
44 return size == ret; 46 return size == ret;
45} 47}
46 48
47static int enable_events(int fd, char* str) 49static int enable_event(int fd, char* str)
48{ 50{
49 cmd_t *id; 51 cmd_t *id;
50 cmd_t cmd[2]; 52 cmd_t cmd[2];
51 53
52 id = ids + event_count; 54 id = ids + event_count;
53 if (!str2event(str, id)) 55 if (!str2event(str, id)) {
56 errno = EINVAL;
54 return 0; 57 return 0;
58 }
55 59
56 event_count += 1; 60 event_count += 1;
57 cmd[0] = ENABLE_CMD; 61 cmd[0] = ENABLE_CMD;
@@ -60,7 +64,7 @@ static int enable_events(int fd, char* str)
60} 64}
61 65
62 66
63static void cat2stdout(int fd) 67static void cat2stdout(int fd)
64{ 68{
65 static char buf[4096]; 69 static char buf[4096];
66 int rd; 70 int rd;
@@ -73,7 +77,7 @@ static void cat2stdout(int fd)
73 77
74static void usage(void) 78static void usage(void)
75{ 79{
76 fprintf(stderr, 80 fprintf(stderr,
77 "Usage: ftcat <ft device> TS1 TS2 ...." 81 "Usage: ftcat <ft device> TS1 TS2 ...."
78 "\n"); 82 "\n");
79 exit(1); 83 exit(1);
@@ -94,12 +98,12 @@ static void shutdown(int sig)
94 fprintf(stderr, "disable_all: %m\n"); 98 fprintf(stderr, "disable_all: %m\n");
95} 99}
96 100
97int main(int argc, char** argv) 101int main(int argc, char** argv)
98{ 102{
99 const char* trace_file; 103 const char* trace_file;
100 if (argc < 3) 104 if (argc < 3)
101 usage(); 105 usage();
102 106
103 trace_file = argv[1]; 107 trace_file = argv[1];
104 fd = open(trace_file, O_RDWR); 108 fd = open(trace_file, O_RDWR);
105 if (fd < 0) { 109 if (fd < 0) {
@@ -112,7 +116,7 @@ int main(int argc, char** argv)
112 signal(SIGUSR1, shutdown); 116 signal(SIGUSR1, shutdown);
113 signal(SIGTERM, shutdown); 117 signal(SIGTERM, shutdown);
114 while (argc--) { 118 while (argc--) {
115 if (!enable_events(fd, *argv)) { 119 if (!enable_event(fd, *argv)) {
116 fprintf(stderr, "Enabling %s failed: %m\n", *argv); 120 fprintf(stderr, "Enabling %s failed: %m\n", *argv);
117 return 2; 121 return 2;
118 } 122 }