Merge branch 'master' of ssh://git.samba.org/data/git/samba into arc4
[ira/wip.git] / source3 / nmbd / nmbd_browserdb.c
index 443edf599d058eaa5d5486435e51aeb5a7ce2bab..a2793649787411c37c37a89685bcc3f052bd7ce6 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
 */
 /* -------------------------------------------------------------------------- **
@@ -35,7 +34,7 @@
  *  lmb_browserlist - This is our local master browser list. 
  */
 
-ubi_dlNewList( lmb_browserlist );
+struct browse_cache_record *lmb_browserlist;
 
 /* -------------------------------------------------------------------------- **
  * Functions...
@@ -52,7 +51,8 @@ ubi_dlNewList( lmb_browserlist );
  */
 static void remove_lmb_browser_entry( struct browse_cache_record *browc )
 {
-       safe_free( ubi_dlRemThis( lmb_browserlist, browc ) );
+       DLIST_REMOVE(lmb_browserlist, browc);
+       SAFE_FREE(browc);
 }
 
 /* ************************************************************************** **
@@ -87,7 +87,7 @@ struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name,
        struct browse_cache_record *browc;
        time_t now = time( NULL );
 
-       browc = (struct browse_cache_record *)malloc( sizeof( *browc ) );
+       browc = SMB_MALLOC_P(struct browse_cache_record);
 
        if( NULL == browc ) {
                DEBUG( 0, ("create_browser_in_lmb_cache: malloc fail !\n") );
@@ -106,14 +106,14 @@ struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name,
        /* Allow the new lmb to miss an announce period before we remove it. */
        browc->death_time = now + ( (CHECK_TIME_MST_ANNOUNCE + 2) * 60 );
 
-       nstrcpy(  browc->lmb_name, browser_name);
-       nstrcpy(  browc->work_group, work_name);
+       unstrcpy( browc->lmb_name, browser_name);
+       unstrcpy( browc->work_group, work_name);
        strupper_m( browc->lmb_name );
        strupper_m( browc->work_group );
   
        browc->ip = ip;
  
-       (void)ubi_dlAddTail( lmb_browserlist, browc );
+       DLIST_ADD_END(lmb_browserlist, browc, struct browse_cache_record *);
 
        if( DEBUGLVL( 3 ) ) {
                Debug1( "nmbd_browserdb:create_browser_in_lmb_cache()\n" );
@@ -138,12 +138,13 @@ struct browse_cache_record *find_browser_in_lmb_cache( const char *browser_name
 {
        struct browse_cache_record *browc;
 
-       for( browc = (struct browse_cache_record *)ubi_dlFirst( lmb_browserlist );
-                       browc; browc = (struct browse_cache_record *)ubi_dlNext( browc ) )
-               if( strequal( browser_name, browc->lmb_name ) )
+       for( browc = lmb_browserlist; browc; browc = browc->next ) {
+               if( strequal( browser_name, browc->lmb_name ) ) {
                        break;
+               }
+       }
 
-       return( browc );
+       return browc;
 }
 
 /* ************************************************************************** **
@@ -160,9 +161,8 @@ void expire_lmb_browsers( time_t t )
        struct browse_cache_record *browc;
        struct browse_cache_record *nextbrowc;
 
-       for( browc = (struct browse_cache_record *)ubi_dlFirst( lmb_browserlist );
-                       browc; browc = nextbrowc ) {
-               nextbrowc = (struct browse_cache_record *)ubi_dlNext( browc );
+       for( browc = lmb_browserlist; browc; browc = nextbrowc) {
+               nextbrowc = browc->next;
 
                if( browc->death_time < t ) {
                        if( DEBUGLVL( 3 ) ) {