NIO CommKit Host Interface Installation and System Administration Manual
6-21
Porting CommKit Applications To Release 4.x
Examples
Examples
The code fragments shown in Figure 6-1 through Figure 6-9 are examples of
the new library functions. Some of the code is taken out of context from
user-level commands. The intent of this section is to provide porting
examples and is not to present a tutorial in application programming.
For more information on the individual library functions, refer to the manual
pages, which are available online and also in the Appendix E, “CommKit
Manual Pages”.
dk_info Example
The example in Figure 6-1 is a self-contained program that shows the three
commands that are part of the dk_info library function.
Figure 6-1 dk_info Example
1 #include <stdio.h>
2 #include <dkit/dk.h>
3
4 dk_intfchan_t myic;
5 dk urpwin t myuw;
6
7 main() {
8
9 int fd;
10
11 fd = fileno( stdin );
12
13 if( dk_info(fd, DKGETIC, &myic) < 0 ) {
14 fprintf(stderr, "dk_info DKGETIC failed \n"
);
15 }
16
17 else {
18
19 fprintf(stderr,
20 "intf=%d chan=%d \n", myic.iface,
21 myic.chan);
22 }
23 if ( dk_info(fd, DKGETUW, &myuw) < 0 ) {
24 fprintf(stderr, "dk_info DKGETUW failed \n" );
25
26 }
27 else {
28 fprintf(stderr,
29 "maxblocks=%d maxbytes=%d \n",
30 myuw.maxblocks, myuwmaxbytes);
31 }