s4-netlogon: implement dcesrv_netr_DsRAddressToSitenamesExW
[Samba/aatanasov.git] / examples / libsmbclient / testchmod.c
blob774daaed5968fc3c9e80829e2cb30ef7f6d1d986
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <string.h>
4 #include <time.h>
5 #include <libsmbclient.h>
6 #include "get_auth_data_fn.h"
9 int main(int argc, char * argv[])
11 int ret;
12 int debug = 0;
13 int mode = 0666;
14 char buffer[16384];
15 char * pSmbPath = NULL;
16 struct stat st;
18 if (argc == 1)
20 pSmbPath = "smb://RANDOM/Public/small";
22 else if (argc == 2)
24 pSmbPath = argv[1];
26 else if (argc == 3)
28 pSmbPath = argv[1];
29 mode = (int) strtol(argv[2], NULL, 8);
31 else
33 printf("usage: "
34 "%s [ smb://path/to/file [ octal_mode ] ]\n",
35 argv[0]);
36 return 1;
39 smbc_init(get_auth_data_fn, debug);
41 if (smbc_stat(pSmbPath, &st) < 0)
43 perror("smbc_stat");
44 return 1;
47 printf("\nBefore chmod: mode = %04o\n", st.st_mode);
49 if (smbc_chmod(pSmbPath, mode) < 0)
51 perror("smbc_chmod");
52 return 1;
55 if (smbc_stat(pSmbPath, &st) < 0)
57 perror("smbc_stat");
58 return 1;
61 printf("After chmod: mode = %04o\n", st.st_mode);
63 return 0;