Changeset 988 for vendor/current/examples/libsmbclient/testbrowse2.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.