_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size
[xfstests-dev.git] / dmapi / src / simple / dm_find_eventmsg.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/errno.h>
9 #include <getopt.h>
10 #ifdef linux
11 #include <dmapi.h>
12 #endif
13
14 int
15 main( int argc, char **argv )
16 {
17         extern char *optarg;
18         int c;
19         int ret;
20         dm_sessid_t sid = 0;
21         dm_token_t token = 0;
22         dm_eventmsg_t msg;
23         size_t rlen;
24         int buflen = sizeof(dm_eventmsg_t) + 100;
25         char *versionstr;
26
27         while( (c = getopt(argc, argv, "hs:t:l:q")) != -1 ) {
28                 switch(c){
29                 case 's':
30                         sid = atoi( optarg );
31                         break;
32                 case 't':
33                         token = atoi( optarg );
34                         break;
35                 case 'l':
36                         buflen = atoi( optarg );
37                         break;
38                 case 'q':
39                         printf("dm_eventmsg_t=%zd\n", sizeof(dm_eventmsg_t) );
40                         exit(0);
41                 case 'h':
42                         fprintf(stderr, "Usage: %s <-s sid> <-t token> [-l buflen]\n", argv[0]);
43                         fprintf(stderr, "       %s -q\n", argv[0]);
44                         exit(2);
45                 }
46         }
47
48         if( sid == 0 ){
49                 fprintf(stderr, "%s: must specify -s\n", argv[0] );
50                 exit(1);
51         }
52
53         if( token == 0 ){
54                 fprintf(stderr, "%s: must specify -t\n", argv[0] );
55                 exit(1);
56         }
57
58         if( dm_init_service( &versionstr ) < 0 )
59                 exit(1);
60
61         ret = dm_find_eventmsg( sid, token, buflen, &msg, &rlen );
62         printf( "ret=%d\n", ret );
63         printf( "rlen=%zd\n", rlen );
64         exit(0);
65 }