4 * Decode CAPS encoded buffers, one per line, into a struct passwd and
7 * $DragonFly: src/test/caps/decoder.c,v 1.1 2004/03/08 00:36:45 dillon Exp $
10 #include <libcaps/caps_struct.h>
16 main(int ac
, char **av
)
25 while (fgets(buf
, sizeof(buf
), stdin
) != NULL
) {
27 bzero(&pw
, sizeof(pw
));
28 n
= caps_decode(buf
, len
, &pw
, &caps_passwd_struct
, &error
);
29 printf("decode %d bytes error %d\n", n
, error
);
33 if (n
&& buf
[n
] == '\n') /* don't highlight a 'newline' */
35 printf("%*.*s", n
, n
, buf
);
36 printf("\033[7m%c\033[m", buf
[n
]);
39 printf("%*.*s", n
, n
, buf
+ len
- n
);
42 printf(" pw_name = \"%s\"\n", pw
.pw_name
);
43 printf(" pw_passwd = \"%s\"\n", pw
.pw_passwd
);
44 printf(" pw_uid = %d\n", pw
.pw_uid
);
45 printf(" pw_gid = %d\n", pw
.pw_gid
);
46 printf(" pw_change = %08llx\n", (long long)pw
.pw_change
);
47 printf(" pw_class = \"%s\"\n", pw
.pw_class
);
48 printf(" pw_gecos = \"%s\"\n", pw
.pw_gecos
);
49 printf(" pw_dir = \"%s\"\n", pw
.pw_dir
);
50 printf(" pw_shell = \"%s\"\n", pw
.pw_shell
);
51 printf(" pw_expire = %08llx\n", (long long)pw
.pw_expire
);
54 caps_struct_free_pointers(&pw
, &caps_passwd_struct
);