Fix a boatload of warnings in the examples.
[nivanova/samba-autobuild/.git] / examples / libsmbclient / teststatvfs.c
1 #include <sys/types.h>
2 #include <sys/statvfs.h>
3 #include <stdio.h> 
4 #include <unistd.h>
5 #include <string.h> 
6 #include <time.h> 
7 #include <errno.h>
8 #include <libsmbclient.h> 
9 #include "get_auth_data_fn.h"
10
11
12 int main(int argc, char * argv[]) 
13
14     int             ret;
15     int             debug = 0;
16     char *          p;
17     char            path[2048];
18     struct statvfs  statvfsbuf;
19     
20     smbc_init(get_auth_data_fn, debug); 
21     
22     for (;;)
23     {
24         fprintf(stdout, "Path: ");
25         *path = '\0';
26         fgets(path, sizeof(path) - 1, stdin);
27         if (strlen(path) == 0)
28         {
29             return 0;
30         }
31
32         p = path + strlen(path) - 1;
33         if (*p == '\n')
34         {
35             *p = '\0';
36         }
37     
38         ret = smbc_statvfs(path, &statvfsbuf);
39
40         if (ret < 0)
41         {
42             perror("fstatvfs");
43         }
44         else
45         {
46             printf("\n");
47             printf("Block Size: %lu\n", statvfsbuf.f_bsize);
48             printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
49             printf("Blocks: %llu\n",
50                    (unsigned long long) statvfsbuf.f_blocks);
51             printf("Free Blocks: %llu\n",
52                    (unsigned long long) statvfsbuf.f_bfree);
53             printf("Available Blocks: %llu\n",
54                    (unsigned long long) statvfsbuf.f_bavail);
55             printf("Files : %llu\n",
56                    (unsigned long long) statvfsbuf.f_files);
57             printf("Free Files: %llu\n",
58                    (unsigned long long) statvfsbuf.f_ffree);
59             printf("Available Files: %llu\n",
60                    (unsigned long long) statvfsbuf.f_favail);
61             printf("File System ID: %lu\n",
62                    (unsigned long) statvfsbuf.f_fsid);
63             printf("\n");
64
65             printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
66             printf("Extended Features: ");
67
68             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
69             {
70                 printf("NO_UNIXCIFS ");
71             }
72             else
73             {
74                 printf("unixcifs ");
75             }
76
77             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
78             {
79                 printf("CASE_INSENSITIVE ");
80             }
81             else
82             {
83                 printf("case_sensitive ");
84             }
85
86             if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
87             {
88                 printf("DFS ");
89             }
90             else
91             {
92                 printf("no_dfs ");
93             }
94
95             printf("\n");
96         }
97     }
98
99     return 0; 
100 }