move functions that send messages to traced processes to libustcomm (which is linked...
[ust.git] / ust / ust.c
CommitLineData
fbd8191b
PMF
1#include <unistd.h>
2#include <getopt.h>
3#include <stdlib.h>
4#include <stdio.h>
5#include <fcntl.h>
fbd8191b 6
f9e5ce61 7#include "ustcomm.h"
fbd8191b
PMF
8
9void parse_opts(int argc, char **argv)
10{
11 int flags, opt;
12 int nsecs, tfnd;
13
14 nsecs = 0;
15 tfnd = 0;
16 flags = 0;
17 while ((opt = getopt(argc, argv, "nt:")) != -1) {
18 switch (opt) {
19 case 'n':
20 flags = 1;
21 break;
22 case 't':
23 nsecs = atoi(optarg);
24 tfnd = 1;
25 break;
26 default: /* '?' */
27 fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n",
28 argv[0]);
29 exit(EXIT_FAILURE);
30 }
31 }
32
33 printf("flags=%d; tfnd=%d; optind=%d\n", flags, tfnd, optind);
34
35 if (optind >= argc) {
36 fprintf(stderr, "Expected argument after options\n");
37 exit(EXIT_FAILURE);
38 }
39
40 printf("name argument = %s\n", argv[optind]);
41
42 /* Other code omitted */
43
44 exit(EXIT_SUCCESS);
45
46}
47
fbd8191b
PMF
48int main(int argc, char *argv[])
49{
50 pid_t pid = atoi(argv[1]);
51
52 char *msg = argv[2];
53
f9e5ce61 54 send_message(pid, msg, NULL);
fbd8191b
PMF
55
56 return 0;
57}
This page took 0.024169 seconds and 4 git commands to generate.