libutil - Add humanize_unsigned()
[dragonfly.git] / test / caps / server.c
blobde55d83195fdeb0282fb7459161fdd6cf03d537b
1 /*
2 * $DragonFly: src/test/caps/server.c,v 1.5 2004/08/24 13:45:54 drhodus Exp $
3 */
4 #include <sys/types.h>
5 #include <sys/time.h>
6 #include <sys/caps.h>
7 #include <sys/errno.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
13 int
14 main(int ac, char **av)
16 int cid;
17 int n;
18 int count;
19 char buf[256];
20 struct caps_msgid msgid;
22 count = 0;
24 cid = caps_sys_service("test", getuid(), getgid(), 0, CAPF_ANYCLIENT);
25 if (cid == -1) {
26 perror("caps_sys_service");
27 exit(1);
29 printf("cid = %d\n", cid);
30 if (cid < 0)
31 return(0);
32 bzero(&msgid, sizeof(msgid));
33 for (;;) {
34 n = caps_sys_wait(cid, buf, sizeof(buf), &msgid, NULL);
35 #ifdef DEBUG
36 printf("n = %d msgid=%016llx state=%d errno=%d\n", n, msgid.c_id, msgid.c_state, errno);
37 if (n > 0)
38 printf("BUFFER: %*.*s\n", n, n, buf);
39 #endif
40 if (msgid.c_state != CAPMS_DISPOSE)
41 n = caps_sys_reply(cid, "good", 4, msgid.c_id);
42 #ifdef DEBUG
43 printf("reply: n = %d\n", n);
44 #endif
45 if (++count % 1000000 == 0)
46 caps_sys_setgen(cid, count);
48 return(0);