OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // When run with 2 or more arguments the file_poller tool will open a port on | 5 // When run with 2 or more arguments the file_poller tool will open a port on |
6 // the device, print it on its standard output and then start collect file | 6 // the device, print it on its standard output and then start collect file |
7 // contents. The first argument is the polling rate in Hz, and the following | 7 // contents. The first argument is the polling rate in Hz, and the following |
8 // arguments are file to poll. | 8 // arguments are file to poll. |
9 // When run with the port of an already running file_poller, the tool will | 9 // When run with the port of an already running file_poller, the tool will |
10 // contact the first instance, retrieve the sample and print those on its | 10 // contact the first instance, retrieve the sample and print those on its |
11 // standard output. This will also terminate the first instance. | 11 // standard output. This will also terminate the first instance. |
12 | 12 |
13 #include <errno.h> | 13 #include <errno.h> |
14 #include <fcntl.h> | 14 #include <fcntl.h> |
15 #include <netinet/in.h> | 15 #include <netinet/in.h> |
| 16 #include <stddef.h> |
16 #include <stdio.h> | 17 #include <stdio.h> |
17 #include <stdlib.h> | 18 #include <stdlib.h> |
18 #include <sys/socket.h> | 19 #include <sys/socket.h> |
19 #include <sys/stat.h> | 20 #include <sys/stat.h> |
20 #include <sys/time.h> | 21 #include <sys/time.h> |
21 #include <sys/types.h> | 22 #include <sys/types.h> |
22 #include <unistd.h> | 23 #include <unistd.h> |
23 | 24 |
24 #include "base/logging.h" | 25 #include "base/logging.h" |
25 | 26 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Context context; | 199 Context context; |
199 context.poll_rate = atoi(argv[1]); | 200 context.poll_rate = atoi(argv[1]); |
200 context.nb_files = argc - 2; | 201 context.nb_files = argc - 2; |
201 context.file_fds = new int[context.nb_files]; | 202 context.file_fds = new int[context.nb_files]; |
202 for (int i = 2; i < argc; ++i) | 203 for (int i = 2; i < argc; ++i) |
203 context.file_fds[i - 2] = checked_open(argv[i]); | 204 context.file_fds[i - 2] = checked_open(argv[i]); |
204 poll_content(context); | 205 poll_content(context); |
205 } | 206 } |
206 return EXIT_SUCCESS; | 207 return EXIT_SUCCESS; |
207 } | 208 } |
OLD | NEW |