Correzioni rimaste indietro ed espansione funzioni del resolver.
[gapil.git] / listati / mygetfacl.c
1 #include <sys/types.h>   /* primitive system data types */
2 #include <stdlib.h>      /* C standard library */
3 #include <stdio.h>       /* standard I/O library */
4 #include <unistd.h>      /* unix standard library */
5 #include <sys/acl.h>     /* acl library (use -l acl) */
6
7 int main(int argc, char *argv[])
8 {
9 /*
10  * Variables definition
11  */    
12     acl_t acl;
13     ssize_t size;
14     char * buffer;
15     ...
16     /* must have an argument */
17     if ((argc - optind) != 1) {
18         printf("Wrong number of arguments %d\n", argc - optind);
19         usage();
20     }
21     /* main body */
22     acl = acl_get_file(argv[1], ACL_TYPE_ACCESS);
23     if (acl == NULL) {
24         perror("cannot get acl for file");
25         return 1;
26     }
27     buffer = acl_to_text(acl, &size);
28     if (buffer == NULL) {
29         perror("cannot convert acl");
30         return 1;
31     }
32     printf("ACL for file '%s':\n%s\n", argv[1], buffer);
33     acl_free(acl);
34     acl_free(buffer);
35     return 0;
36 }