Doxygen Source Code Documentation
thd_trusthost.c File Reference
#include <string.h>#include <stdlib.h>#include <stdio.h>#include "afni_environ.h"#include "Amalloc.h"#include "niml.h"#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <arpa/inet.h>#include <ctype.h>Go to the source code of this file.
| Defines | |
| #define | INIT_NUM (sizeof(init_hosts)/sizeof(char *)) | 
| #define | HSIZE 32 | 
| #define | USE_NIML | 
| Functions | |
| char * | xxx_name_to_inet (char *host) | 
| void | add_TRUST_host (char *hnam) | 
| void | init_TRUST_list (void) | 
| void | TRUST_addhost (char *hostname) | 
| int | TRUST_host (char *hostid) | 
| Variables | |
| int | host_num = 0 | 
| char ** | host_list = NULL | 
| char * | init_hosts [] | 
Define Documentation
| 
 | 
| 
 Definition at line 26 of file thd_trusthost.c. Referenced by add_TRUST_host(), and init_TRUST_list(). | 
| 
 | 
| 
 Definition at line 25 of file thd_trusthost.c. Referenced by init_TRUST_list(). | 
| 
 | 
| 
 Definition at line 28 of file thd_trusthost.c. | 
Function Documentation
| 
 | 
| 
 Definition at line 68 of file thd_trusthost.c. References free, host_list, host_num, HSIZE, malloc, realloc, and xxx_name_to_inet(). Referenced by init_TRUST_list(), and TRUST_addhost(). 
 00069 {
00070    char *hh=NULL ;
00071    int nh,ii ;
00072 
00073    if( hnam == NULL || hnam[0] == '\0' ) return ;
00074 
00075    /* see if host name is consistent with 012.345.678.901 format */
00076 
00077    nh = strlen(hnam) ;
00078    for( ii=0 ; ii < nh ; ii++ )
00079       if( !isdigit(hnam[ii]) && hnam[ii] != '.' ) break ;
00080 
00081    if( ii < nh ){                     /* not a dotted number */
00082       hh = xxx_name_to_inet( hnam ) ; /* so do a lookup on it */
00083       if( hh == NULL ) return ;       /* failed? */
00084 
00085    } else if( nh > HSIZE-1 ){         /* something bad? */
00086       return ;
00087    } else {
00088       hh = hnam ;                     /* store dotted number */
00089    }
00090 
00091    host_list = (char **) realloc(host_list,sizeof(char *)*(host_num+1)) ;
00092    host_list[host_num] = (char *) malloc(HSIZE) ;
00093    strcpy( host_list[host_num] , hh ) ; host_num++ ;
00094 
00095    if( hh != hnam ) free(hh) ;
00096    return ;
00097 }
 | 
| 
 | 
| 
 Definition at line 103 of file thd_trusthost.c. References add_TRUST_host(), host_list, host_num, HSIZE, init_hosts, INIT_NUM, malloc, and my_getenv(). Referenced by TRUST_addhost(), and TRUST_host(). 
 00104 {
00105    int ii ;
00106    char ename[HSIZE] , *str ;
00107 
00108    if( host_num == 0 ){
00109       host_num = INIT_NUM ;
00110       host_list = (char **) malloc( sizeof(char *) * INIT_NUM ) ;
00111       for( ii=0 ; ii < INIT_NUM ; ii++ ){
00112          host_list[ii] = (char *) malloc(HSIZE) ;
00113          strcpy( host_list[ii] , init_hosts[ii] ) ;
00114       }
00115 
00116       str = my_getenv("AFNI_TRUSTHOST") ;
00117       if( str != NULL ) add_TRUST_host(str) ;
00118 
00119       for( ii=1 ; ii <= 99 ; ii++ ){
00120          sprintf(ename,"AFNI_TRUSTHOST_%d",ii) ; str = my_getenv(ename) ;
00121          if( str == NULL && ii <= 9 ){
00122            sprintf(ename,"AFNI_TRUSTHOST_%02d",ii) ; str = my_getenv(ename) ;
00123          }
00124          if( str != NULL ) add_TRUST_host(str) ;
00125       }
00126    }
00127 
00128    return ;
00129 }
 | 
| 
 | 
| 
 Definition at line 135 of file thd_trusthost.c. References add_TRUST_host(), host_num, init_TRUST_list(), and NI_add_trusted_host(). Referenced by ENV_trusthost(). 
 00136 {
00137    if( hostname == NULL || hostname[0] == '\0' ) return ;
00138    if( host_num == 0 ) init_TRUST_list() ;
00139    add_TRUST_host(hostname) ;
00140 #ifdef USE_NIML
00141    NI_add_trusted_host(hostname) ;
00142 #endif
00143    return ;
00144 }
 | 
| 
 | 
| 
 Definition at line 150 of file thd_trusthost.c. References host_list, host_num, and init_TRUST_list(). Referenced by AFNI_plugout_workproc(), MAIN_workprocess(), and RT_check_listen(). 
 00151 {
00152    int ii ;
00153 
00154    if( host_num == 0 ) init_TRUST_list() ;
00155 
00156    if( hostid == NULL || hostid[0] == '\0' ) return 0 ;
00157 
00158    for( ii=0 ; ii < host_num ; ii++ )
00159       if( strstr(hostid,host_list[ii]) == hostid ) return 1 ;
00160 
00161    return 0 ;
00162 }
 | 
| 
 | 
| 
 Definition at line 45 of file thd_trusthost.c. References AFMALL. 
 00046 {
00047    struct hostent *hostp ;
00048    char *iname = NULL , *str ;
00049    int ll ;
00050 
00051    if( host == NULL || host[0] == '\0' ) return NULL ;
00052 
00053    hostp = gethostbyname(host) ; if( hostp == NULL ) return NULL ;
00054 
00055    str = inet_ntoa(*((struct in_addr *)(hostp->h_addr))) ;
00056    if( str == NULL || str[0] == '\0' ) return NULL ;
00057 
00058    ll = strlen(str) ; iname = AFMALL(char, ll+1) ; strcpy(iname,str) ;
00059    return iname ;
00060 }
 | 
Variable Documentation
| 
 | 
| 
 Definition at line 17 of file thd_trusthost.c. Referenced by add_TRUST_host(), init_TRUST_list(), and TRUST_host(). | 
| 
 | 
| 
 Definition at line 16 of file thd_trusthost.c. Referenced by add_TRUST_host(), init_TRUST_list(), TRUST_addhost(), and TRUST_host(). | 
| 
 | 
| Initial value:  { 
    "141.106.106." ,            
    "128.231."     ,           
    "127.0.0.1"    ,           
    "192.168."                 
}Definition at line 19 of file thd_trusthost.c. Referenced by init_TRUST_list(). | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  