~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/wrepld/socket.c

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
   Unix SMB/CIFS implementation.
3
 
   process incoming packets - main loop
4
 
   Copyright (C) Jean Fran�ois Micouleau      1998-2002.
5
 
   
6
 
   This program is free software; you can redistribute it and/or modify
7
 
   it under the terms of the GNU General Public License as published by
8
 
   the Free Software Foundation; either version 2 of the License, or
9
 
   (at your option) any later version.
10
 
   
11
 
   This program is distributed in the hope that it will be useful,
12
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
   GNU General Public License for more details.
15
 
   
16
 
   You should have received a copy of the GNU General Public License
17
 
   along with this program; if not, write to the Free Software
18
 
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 
*/
20
 
 
21
 
#include "includes.h"
22
 
#include "wins_repl.h"
23
 
 
24
 
fd_set *listen_set = NULL;
25
 
int listen_number = 0;
26
 
int *sock_array = NULL;
27
 
 
28
 
/*******************************************************************
29
 
  Add an fd from the sock_array
30
 
******************************************************************/
31
 
void add_fd_to_sock_array(int fd)
32
 
{
33
 
        int *temp_sock=NULL;
34
 
 
35
 
        temp_sock=(int *)Realloc(sock_array, (listen_number+1)*sizeof(int));
36
 
        if (temp_sock==NULL)
37
 
                return;
38
 
 
39
 
        sock_array=temp_sock;
40
 
        sock_array[listen_number]=fd;
41
 
        listen_number++;
42
 
}
43
 
 
44
 
 
45
 
/*******************************************************************
46
 
  Remove an fd from the sock_array
47
 
******************************************************************/
48
 
void remove_fd_from_sock_array(int fd)
49
 
{
50
 
        int i,j;
51
 
 
52
 
        for (i=0; sock_array[i]!=fd && i<listen_number; i++)
53
 
                ;
54
 
        
55
 
        if (i==listen_number) {
56
 
                DEBUG(0,("remove_fd_from_sock_array: unknown fd: %d\n", fd));
57
 
                return;
58
 
        }
59
 
        
60
 
        if (i==listen_number-1) {
61
 
                sock_array=(int *)Realloc(sock_array, --listen_number*sizeof(int));
62
 
                return;
63
 
        }
64
 
 
65
 
        for (j=i; j<listen_number-1; j++)
66
 
                sock_array[j]=sock_array[j+1];
67
 
        
68
 
        sock_array=(int *)Realloc(sock_array, --listen_number*sizeof(int));     
69
 
}