Ignore:
Timestamp:
01/21/08 08:37:07 (16 years ago)
Author:
niltonneto
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/socket/server.c

    r151 r159  
    280280        struct cat * info; 
    281281        pthread_t cat_thread; 
     282         
     283        FILE *file; 
     284        char line[80]; 
     285        char *ips[20]; 
     286        int cont; 
     287        int j; 
    282288 
    283289        unsigned int addr = 0; 
     
    289295        printf("New connection: %s\n\n", buf); 
    290296 
    291         if ( strcmp(buf, "10.15.20.42") == 0 || strcmp(buf, "10.15.20.202") == 0 ) 
     297        if(!(file = fopen("/etc/socket_im/hosts","r"))) 
     298        { 
     299                printf("Impossível abrir o arquivo hosts \n"); 
     300                exit(1); 
     301        } 
     302         
     303        fgets(line, 80, file); 
     304        while(!feof(file)) 
     305        { 
     306                ips[cont] = malloc(sizeof(char)*17); 
     307                line[strlen(line) - 1 ] = '\0'; 
     308                strcpy(ips[cont], line); 
     309                fgets(line, 80, file); 
     310                cont++; 
     311        } 
     312         
     313        fclose(file); 
     314 
     315        for( j = 0; j < cont; j++) 
     316        { 
     317                if( strcmp( buf, ips[j] ) == 0) 
     318                { 
     319                        user = Handshake(client->newfd); 
     320                        jabber_fd = user->jabber_fd; 
     321                        break; 
     322                } 
     323        } 
     324 
     325        /*if ( strcmp(buf, "10.15.20.42") == 0 || strcmp(buf, "10.15.20.202") == 0 || strcmp(buf, "10.15.20.145") == 0 ) 
    292326        { 
    293327                user = Handshake(client->newfd); 
    294328                jabber_fd = user->jabber_fd; 
    295         } 
     329        }*/ 
    296330 
    297331        if ( jabber_fd == (int)NULL ) 
Note: See TracChangeset for help on using the changeset viewer.