Changeset 988 for vendor/current/examples/libsmbclient
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/examples/libsmbclient
- Files:
-
- 2 added
- 1 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/examples/libsmbclient/Makefile
r414 r988 8 8 EXTLIB_INCL = `gtk-config --cflags` 9 9 10 DEFS = -D_ LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE10 DEFS = -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 11 11 CFLAGS = -O0 -g $(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS) 12 12 -
vendor/current/examples/libsmbclient/get_auth_data_fn.h
r414 r988 17 17 char username[256] = { '\0' }; 18 18 char password[256] = { '\0' }; 19 char *ret; 19 20 20 21 static int krb5_set = 1; … … 37 38 38 39 fprintf(stdout, "Workgroup: [%s] ", pWorkgroup); 39 fgets(temp, sizeof(temp), stdin); 40 ret = fgets(temp, sizeof(temp), stdin); 41 if (ret == NULL) { 42 return; 43 } 40 44 41 45 if (temp[strlen(temp) - 1] == '\n') /* A new line? */ … … 50 54 51 55 fprintf(stdout, "Username: [%s] ", pUsername); 52 fgets(temp, sizeof(temp), stdin); 56 ret = fgets(temp, sizeof(temp), stdin); 57 if (ret == NULL) { 58 return; 59 } 53 60 54 61 if (temp[strlen(temp) - 1] == '\n') /* A new line? */ … … 63 70 64 71 fprintf(stdout, "Password: "); 65 fgets(temp, sizeof(temp), stdin); 72 ret = fgets(temp, sizeof(temp), stdin); 73 if (ret == NULL) { 74 return; 75 } 66 76 67 77 if (temp[strlen(temp) - 1] == '\n') /* A new line? */ -
vendor/current/examples/libsmbclient/testacl.c
r414 r988 22 22 { 23 23 int opt; 24 int flags ;24 int flags = 0; 25 25 int debug = 0; 26 26 int numeric = 0; … … 28 28 int full_time_names = 0; 29 29 enum acl_mode mode = SMB_ACL_LIST; 30 static c har *the_acl = NULL;30 static const char *the_acl = NULL; 31 31 int ret; 32 32 char *p; 33 c har *debugstr;33 const char *debugstr; 34 34 char path[1024]; 35 35 char value[1024]; -
vendor/current/examples/libsmbclient/testacl2.c
r414 r988 20 20 int main(int argc, const char *argv[]) 21 21 { 22 int i;23 int opt;24 22 int flags; 25 23 int debug = 0; 26 int numeric = 0;27 int full_time_names = 0;28 enum acl_mode mode = SMB_ACL_GET;29 24 static char *the_acl = NULL; 30 25 int ret; 31 char *p; 32 char *debugstr; 26 const char *debugstr; 33 27 char value[1024]; 28 SMBCCTX *context; 34 29 35 30 if (smbc_init(get_auth_data_fn, debug) != 0) … … 39 34 } 40 35 41 SMBCCTX *context = smbc_set_context(NULL);36 context = smbc_set_context(NULL); 42 37 smbc_setOptionFullTimeNames(context, 1); 43 38 -
vendor/current/examples/libsmbclient/testacl3.c
r414 r988 11 11 int main(int argc, char * argv[]) 12 12 { 13 int i;14 int fd;15 13 int ret; 16 14 int debug = 0; 17 int mode = 0666;18 int savedErrno;19 15 char value[2048]; 20 16 char path[2048]; 21 17 char * the_acl; 22 18 char * p; 23 time_t t0;24 time_t t1;25 struct stat st;26 19 SMBCCTX * context; 27 20 -
vendor/current/examples/libsmbclient/testbrowse.c
r414 r988 10 10 #include "get_auth_data_fn.h" 11 11 12 static void13 no_auth_data_fn(const char * pServer,14 const char * pShare,15 char * pWorkgroup,16 int maxLenWorkgroup,17 char * pUsername,18 int maxLenUsername,19 char * pPassword,20 int maxLenPassword);21 22 12 static void browse(char * path, 23 13 int scan, … … 36 26 int maxLenPassword); 37 27 38 int 39 main(int argc, char * argv[]) 28 int main(int argc, const char *argv[]) 40 29 { 41 30 int debug = 0; … … 45 34 int scan = 0; 46 35 int iterations = -1; 47 int again;48 36 int opt; 49 37 char * p; 50 char * q;51 38 char buf[1024]; 52 39 poptContext pc; … … 86 73 setbuf(stdout, NULL); 87 74 88 pc = poptGetContext("opendir", argc, (const char **)argv, long_options, 0);75 pc = poptGetContext("opendir", argc, argv, long_options, 0); 89 76 90 77 poptSetOtherOptionHelp(pc, ""); … … 113 100 smbc_setFunctionAuthDataWithContext(context, 114 101 get_auth_data_with_context_fn); 115 smbc_setOptionUserData(context, "hello world");102 smbc_setOptionUserData(context, strdup("hello world")); 116 103 } else { 117 104 smbc_setFunctionAuthData(context, get_auth_data_fn); … … 139 126 if (scan) 140 127 { 141 for (; 142 iterations == -1 || iterations > 0; 143 iterations = (iterations == -1 ? iterations : --iterations)) 144 { 128 for (; iterations != 0;) { 129 if (iterations > 0) { 130 iterations--; 131 } 132 145 133 snprintf(buf, sizeof(buf), "smb://"); 146 134 browse(buf, scan, 0); … … 149 137 else 150 138 { 151 for (; 152 iterations == -1 || iterations > 0; 153 iterations = (iterations == -1 ? iterations : --iterations)) 154 { 139 for (; iterations != 0;) { 140 if (iterations > 0) { 141 iterations--; 142 } 143 155 144 fputs("url: ", stdout); 156 145 p = fgets(buf, sizeof(buf), stdin); … … 171 160 exit(0); 172 161 } 173 174 175 static void176 no_auth_data_fn(const char * pServer,177 const char * pShare,178 char * pWorkgroup,179 int maxLenWorkgroup,180 char * pUsername,181 int maxLenUsername,182 char * pPassword,183 int maxLenPassword)184 {185 return;186 }187 188 162 189 163 static void … … 214 188 char buf[1024]; 215 189 int dir; 216 struct stat st at;190 struct stat st; 217 191 struct smbc_dirent * dirent; 218 192 … … 269 243 strcat(p, "/"); 270 244 strcat(p+1, dirent->name); 271 if (smbc_stat(path, &st at) < 0)245 if (smbc_stat(path, &st) < 0) 272 246 { 273 247 printf(" unknown size (reason %d: %s)", … … 276 250 else 277 251 { 278 printf(" size %lu", (unsigned long) st at.st_size);252 printf(" size %lu", (unsigned long) st.st_size); 279 253 } 280 254 *p = '\0'; -
vendor/current/examples/libsmbclient/testbrowse2.c
r414 r988 6 6 #include <stdio.h> 7 7 #include <stdlib.h> 8 #include <malloc.h>9 8 #include <string.h> 10 9 #include <libsmbclient.h> 11 10 12 11 int debuglevel = 0; 13 c har *workgroup = "NT";14 c har *username = "guest";15 c har *password = "";12 const char *workgroup = "NT"; 13 const char *username = "guest"; 14 const char *password = ""; 16 15 17 16 typedef struct smbitem smbitem; … … 24 23 }; 25 24 26 int smbitem_cmp(smbitem *elem1, smbitem *elem2){ 27 return strcmp(elem1->name, elem2->name); 28 } 29 30 int smbitem_list_count(smbitem *list){ 31 int count = 0; 32 33 while(list != NULL){ 34 list = list->next; 35 count++; 36 } 37 return count; 38 } 39 40 void smbitem_list_delete(smbitem *list){ 41 smbitem *elem; 42 43 while(list != NULL){ 44 elem = list; 45 list = list->next; 46 free(elem); 47 } 48 } 49 50 smbitem* smbitem_list_sort(smbitem *list){ 51 smbitem *item, **array; 52 int count, i; 53 54 if ((count = smbitem_list_count(list)) == 0) return NULL; 55 if ((array = malloc(count * sizeof(smbitem*))) == NULL){ 56 smbitem_list_delete(list); 57 return NULL; 58 } 59 60 for(i = 0; i < count; i++){ 61 array[i] = list; 62 list = list->next; 63 } 64 qsort(array, count, sizeof(smbitem*), (qsort_cmp)smbitem_cmp); 65 66 for(i = 0; i < count - 1; i++) array[i]->next = array[i + 1]; 67 array[count - 1]->next = NULL; 68 69 list = array[0]; 70 free(array); 71 return list; 72 } 73 74 void smbc_auth_fn( 25 static void smbc_auth_fn( 75 26 const char *server, 76 27 const char *share, … … 89 40 } 90 41 91 SMBCCTX* create_smbctx(){42 static SMBCCTX* create_smbctx(void){ 92 43 SMBCCTX *ctx; 93 44 … … 105 56 } 106 57 107 void delete_smbctx(SMBCCTX* ctx){58 static void delete_smbctx(SMBCCTX* ctx){ 108 59 smbc_getFunctionPurgeCachedServers(ctx)(ctx); 109 60 smbc_free_context(ctx, 1); 110 61 } 111 62 112 s mbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){63 static smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){ 113 64 SMBCFILE *fd; 114 65 struct smbc_dirent *dirent; … … 135 86 } 136 87 137 void print_smb_path(char *group,char *path){88 static void print_smb_path(const char *group, const char *path){ 138 89 if ((strlen(group) == 0) && (strlen(path) == 0)) printf("/\n"); 139 90 else if (strlen(path) == 0) printf("/%s\n", group); … … 144 95 } 145 96 146 void recurse(SMBCCTX *ctx,char *smb_group, char *smb_path, int maxlen){97 static void recurse(SMBCCTX *ctx, const char *smb_group, char *smb_path, int maxlen){ 147 98 int len; 148 99 smbitem *list, *item; -
vendor/current/examples/libsmbclient/testchmod.c
r414 r988 9 9 int main(int argc, char * argv[]) 10 10 { 11 int ret;12 11 int debug = 0; 13 12 int mode = 0666; 14 char buffer[16384]; 15 char * pSmbPath = NULL; 13 const char * pSmbPath = NULL; 16 14 struct stat st; 17 15 … … 45 43 } 46 44 47 printf("\nBefore chmod: mode = %04o\n", st.st_mode);45 printf("\nBefore chmod: mode = %04o\n", (unsigned int)st.st_mode); 48 46 49 47 if (smbc_chmod(pSmbPath, mode) < 0) … … 59 57 } 60 58 61 printf("After chmod: mode = %04o\n", st.st_mode);59 printf("After chmod: mode = %04o\n", (unsigned int)st.st_mode); 62 60 63 61 return 0; -
vendor/current/examples/libsmbclient/testctx.c
r740 r988 2 2 #include <stdlib.h> 3 3 #include <stdio.h> 4 #include <string.h> 4 5 5 void create_and_destroy_context (void)6 static void create_and_destroy_context (void) 6 7 { 7 8 int i; … … 10 11 /* Both should do the same thing */ 11 12 smbc_setOptionDebugToStderr(ctx, 1); 12 smbc_option_set(ctx, "debug_to_stderr", 1);13 smbc_option_set(ctx, strdup("debug_to_stderr"), 1); 13 14 smbc_setDebug(ctx, 1); 14 15 i = smbc_getDebug(ctx); -
vendor/current/examples/libsmbclient/testfstatvfs.c
r414 r988 12 12 int main(int argc, char * argv[]) 13 13 { 14 int i;15 14 int fd; 16 15 int ret; … … 88 87 printf("Available Files: %llu\n", 89 88 (unsigned long long) statvfsbuf.f_favail); 89 #ifdef HAVE_FSID_INT 90 90 printf("File System ID: %lu\n", 91 91 (unsigned long) statvfsbuf.f_fsid); 92 #endif 92 93 printf("\n"); 93 94 -
vendor/current/examples/libsmbclient/testread.c
r414 r988 11 11 int main(int argc, char * argv[]) 12 12 { 13 int i;14 13 int fd; 15 14 int ret; 16 15 int debug = 0; 17 int mode = 0666;18 16 int savedErrno; 19 17 char buffer[2048]; 20 18 char path[2048]; 21 19 char * p; 22 time_t t0;23 time_t t1;24 struct stat st;25 20 26 21 smbc_init(get_auth_data_fn, debug); -
vendor/current/examples/libsmbclient/testsmbc.c
r414 r988 30 30 #include "get_auth_data_fn.h" 31 31 32 int global_id = 0;33 34 void print_list_fn(struct print_job_info *pji)35 {36 37 fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %lu, User: %s, Name: %s\n",38 pji->id,39 pji->priority,40 (unsigned long) pji->size,41 pji->user,42 pji->name);43 44 global_id = pji->id;45 46 }47 48 32 int main(int argc, char *argv[]) 49 33 { 50 int err, fd, dh1, d h2, dh3, dsize, dirc;34 int err, fd, dh1, dsize, dirc; 51 35 const char *file = "smb://samba/public/testfile.txt"; 52 36 const char *file2 = "smb://samba/public/testfile2.txt"; … … 75 59 } 76 60 77 fprintf(stdout, "Directory handle s: %u, %u, %u\n", dh1, dh2, dh3);61 fprintf(stdout, "Directory handle: %u\n", dh1); 78 62 79 63 /* Now, list those directories, but in funny ways ... */ … … 131 115 /* Now, write some date to the file ... */ 132 116 133 bzero(buff, sizeof(buff));117 memset(buff, '\0', sizeof(buff)); 134 118 strcpy(buff, "Some test data for the moment ..."); 135 119 … … 257 241 258 242 fprintf(stdout, "Stat'ed file: %s. Size = %d, mode = %04X\n", file2, 259 (int)st2.st_size, st2.st_mode);243 (int)st2.st_size, (unsigned int)st2.st_mode); 260 244 fprintf(stdout, " time: %s\n", ctime(&st2.st_atime)); 261 245 fprintf(stdout, "Earlier stat: %s, Size = %d, mode = %04X\n", file, 262 (int)st1.st_size, st1.st_mode);246 (int)st1.st_size, (unsigned int)st1.st_mode); 263 247 fprintf(stdout, " time: %s\n", ctime(&st1.st_atime)); 264 248 -
vendor/current/examples/libsmbclient/teststat.c
r414 r988 10 10 { 11 11 int debug = 0; 12 char buffer[16384]; 13 char mtime[32]; 14 char ctime[32]; 15 char atime[32]; 16 char * pSmbPath = NULL; 17 char * pLocalPath = NULL; 12 char m_time[32]; 13 char c_time[32]; 14 char a_time[32]; 15 const char * pSmbPath = NULL; 16 const char * pLocalPath = NULL; 18 17 struct stat st; 19 18 … … 49 48 } 50 49 51 printf("\nSAMBA\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",52 st.st_mtime, ctime_r(&st.st_mtime, mtime),53 st.st_ctime, ctime_r(&st.st_ctime, ctime),54 st.st_atime, ctime_r(&st.st_atime, atime));50 printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 51 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 52 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 53 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 55 54 56 55 if (pLocalPath != NULL) … … 62 61 } 63 62 64 printf("LOCAL\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",65 st.st_mtime, ctime_r(&st.st_mtime, mtime),66 st.st_ctime, ctime_r(&st.st_ctime, ctime),67 st.st_atime, ctime_r(&st.st_atime, atime));63 printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 64 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 65 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 66 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 68 67 } 69 68 -
vendor/current/examples/libsmbclient/teststat2.c
r740 r988 35 35 const char * pLocalPath) 36 36 { 37 //char *pSmbPath = 0;38 37 struct stat st; 39 char m time[32];40 char c time[32];41 char a time[32];38 char m_time[32]; 39 char c_time[32]; 40 char a_time[32]; 42 41 43 42 smbc_init(get_auth_data_fn, 0); … … 49 48 } 50 49 51 printf("SAMBA\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",52 st.st_mtime, ctime_r(&st.st_mtime, mtime),53 st.st_ctime, ctime_r(&st.st_ctime, ctime),54 st.st_atime, ctime_r(&st.st_atime, atime));50 printf("SAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 51 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 52 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 53 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 55 54 56 55 57 / / check the stat on this file56 /* check the stat on this file */ 58 57 if (stat(pLocalPath, &st) < 0) 59 58 { … … 62 61 } 63 62 64 printf("LOCAL\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",65 st.st_mtime, ctime_r(&st.st_mtime, mtime),66 st.st_ctime, ctime_r(&st.st_ctime, ctime),67 st.st_atime, ctime_r(&st.st_atime, atime));63 printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 64 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 65 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 66 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 68 67 69 68 70 69 return 0; 71 70 } 72 -
vendor/current/examples/libsmbclient/teststat3.c
r414 r988 18 18 struct stat st1; 19 19 struct stat st2; 20 char mtime[32];21 char ctime[32];22 char atime[32];23 20 char * pUrl = argv[1]; 24 21 -
vendor/current/examples/libsmbclient/teststatvfs.c
r414 r988 12 12 int main(int argc, char * argv[]) 13 13 { 14 int i;15 int fd;16 14 int ret; 17 15 int debug = 0; 18 16 char * p; 19 17 char path[2048]; 20 struct stat statbuf;21 18 struct statvfs statvfsbuf; 22 19 … … 62 59 printf("Available Files: %llu\n", 63 60 (unsigned long long) statvfsbuf.f_favail); 61 #ifdef HAVE_FSID_INT 64 62 printf("File System ID: %lu\n", 65 63 (unsigned long) statvfsbuf.f_fsid); 64 #endif 66 65 printf("\n"); 67 66 -
vendor/current/examples/libsmbclient/testtruncate.c
r414 r988 15 15 int savedErrno; 16 16 char buffer[128]; 17 char * pSmbPath = NULL;18 char * pLocalPath = NULL;19 17 struct stat st; 20 18 -
vendor/current/examples/libsmbclient/testutime.c
r414 r988 1 #include "config.h" 1 2 #include <stdio.h> 2 3 #include <unistd.h> … … 9 10 int main(int argc, char * argv[]) 10 11 { 11 int ret;12 12 int debug = 0; 13 char buffer[16384]; 14 char mtime[32]; 15 char ctime[32]; 16 char atime[32]; 17 char * pSmbPath = NULL; 13 char m_time[32]; 14 char c_time[32]; 15 char a_time[32]; 16 const char * pSmbPath = NULL; 18 17 time_t t = time(NULL); 19 struct tm tm;20 18 struct stat st; 21 19 struct utimbuf utimbuf; … … 50 48 } 51 49 52 printf("Before\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",53 st.st_mtime, ctime_r(&st.st_mtime, mtime),54 st.st_ctime, ctime_r(&st.st_ctime, ctime),55 st.st_atime, ctime_r(&st.st_atime, atime));50 printf("Before\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 51 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 52 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 53 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 56 54 57 55 utimbuf.actime = t; /* unchangable (wont change) */ … … 69 67 } 70 68 71 printf("After\n mtime:%l u/%s ctime:%lu/%s atime:%lu/%s\n",72 st.st_mtime, ctime_r(&st.st_mtime, mtime),73 st.st_ctime, ctime_r(&st.st_ctime, ctime),74 st.st_atime, ctime_r(&st.st_atime, atime));69 printf("After\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", 70 (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), 71 (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), 72 (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); 75 73 76 74 return 0; -
vendor/current/examples/libsmbclient/testwrite.c
r414 r988 11 11 int main(int argc, char * argv[]) 12 12 { 13 int i;14 13 int fd; 15 14 int ret; 16 15 int debug = 0; 17 int mode = 0666;18 16 int savedErrno; 19 17 char buffer[2048]; 20 18 char path[2048]; 21 19 char * p; 22 time_t t0;23 time_t t1;24 struct stat st;25 20 26 21 smbc_init(get_auth_data_fn, debug);
Note:
See TracChangeset
for help on using the changeset viewer.