Fix a boatload of warnings in the examples.
[ira/wip.git] / examples / libsmbclient / testbrowse2.c
index 0ac1d72bb43221672e048aeb2b4db8e8fbc4227c..fd0a4e8198f42b50be875ec70aa3fdc3a8432f40 100644 (file)
@@ -10,9 +10,9 @@
 #include <libsmbclient.h>
 
 int    debuglevel      = 0;
-char   *workgroup      = "NT";
-char   *username       = "guest";
-char   *password       = "";
+const char     *workgroup      = "NT";
+const char     *username       = "guest";
+const char     *password       = "";
 
 typedef struct smbitem smbitem;
 typedef int(*qsort_cmp)(const void *, const void *);
@@ -23,55 +23,7 @@ struct smbitem{
     char       name[1];
 };
 
-int smbitem_cmp(smbitem *elem1, smbitem *elem2){
-    return strcmp(elem1->name, elem2->name);
-}
-
-int smbitem_list_count(smbitem *list){
-    int count = 0;
-    
-    while(list != NULL){
-       list = list->next;
-       count++;
-    }
-    return count;
-}
-
-void smbitem_list_delete(smbitem *list){
-    smbitem    *elem;
-    
-    while(list != NULL){
-       elem = list;
-       list = list->next;
-       free(elem);
-    }
-}
-
-smbitem* smbitem_list_sort(smbitem *list){
-    smbitem    *item, **array;
-    int                count, i;
-
-    if ((count = smbitem_list_count(list)) == 0) return NULL;
-    if ((array = malloc(count * sizeof(smbitem*))) == NULL){
-       smbitem_list_delete(list);
-       return NULL;
-    }
-    
-    for(i = 0; i < count; i++){
-       array[i] = list;
-       list = list->next;
-    }  
-    qsort(array, count, sizeof(smbitem*), (qsort_cmp)smbitem_cmp);
-    
-    for(i = 0; i < count - 1; i++) array[i]->next = array[i + 1];
-    array[count - 1]->next = NULL;
-    
-    list = array[0];
-    free(array);
-    return list;
-}
-
-void smbc_auth_fn(
+static void smbc_auth_fn(
                 const char      *server,
                const char      *share,
                char            *wrkgrp, int wrkgrplen,
@@ -88,7 +40,7 @@ void smbc_auth_fn(
     strncpy(passwd, password, passwdlen - 1); passwd[passwdlen - 1] = 0;
 }
 
-SMBCCTX* create_smbctx(){
+static SMBCCTX* create_smbctx(void){
     SMBCCTX    *ctx;
 
     if ((ctx = smbc_new_context()) == NULL) return NULL;
@@ -104,12 +56,12 @@ SMBCCTX* create_smbctx(){
     return ctx;
 }
 
-void delete_smbctx(SMBCCTX* ctx){
+static void delete_smbctx(SMBCCTX* ctx){
     smbc_getFunctionPurgeCachedServers(ctx)(ctx);
     smbc_free_context(ctx, 1);
 }
 
-smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){
+static smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){
     SMBCFILE           *fd;
     struct smbc_dirent *dirent;
     smbitem            *list = NULL, *item;
@@ -134,7 +86,7 @@ smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){
         
 }
 
-void print_smb_path(char *group, char *path){
+static void print_smb_path(const char *group, const char *path){
     if ((strlen(group) == 0) && (strlen(path) == 0)) printf("/\n");
     else if (strlen(path) == 0) printf("/%s\n", group);
     else{
@@ -143,7 +95,7 @@ void print_smb_path(char *group, char *path){
     }
 }
 
-void recurse(SMBCCTX *ctx, char *smb_group, char *smb_path, int maxlen){
+static void recurse(SMBCCTX *ctx, const char *smb_group, char *smb_path, int maxlen){
     int        len;
     smbitem    *list, *item;
     SMBCCTX    *ctx1;