Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

afni_environ.h File Reference

Go to the source code of this file.


Defines

#define YSTART(cp)   ( (cp) != NULL && ( (cp)[0] == 'y' || (cp)[0] == 'Y' ) )
#define NSTART(cp)   ( (cp) != NULL && ( (cp)[0] == 'n' || (cp)[0] == 'N' ) )
#define YESSISH(ss)   ( (ss)!=NULL && ( (ss)[0]=='Y' || (ss)[0]=='y' ) )
#define NOISH(ss)   ( (ss)!=NULL && ( (ss)[0]=='N' || (ss)[0]=='n' ) )

Functions

void AFNI_process_environ (char *)
char * AFNI_suck_file (char *)
char * my_getenv (char *)
void AFNI_mark_environ_done (void)
int AFNI_yesenv (char *)
int AFNI_noenv (char *)
double AFNI_numenv (char *)
int AFNI_setenv (char *cmd)

Define Documentation

#define NOISH ss       ( (ss)!=NULL && ( (ss)[0]=='N' || (ss)[0]=='n' ) )
 

Definition at line 31 of file afni_environ.h.

Referenced by AFNI_noenv(), and PLOT_tsgray().

#define NSTART cp       ( (cp) != NULL && ( (cp)[0] == 'n' || (cp)[0] == 'N' ) )
 

Definition at line 25 of file afni_environ.h.

#define YESSISH ss       ( (ss)!=NULL && ( (ss)[0]=='Y' || (ss)[0]=='y' ) )
 

21 Jun 2000: look for Yes or No *

Definition at line 30 of file afni_environ.h.

Referenced by AFNI_startup_layout_CB(), AFNI_yesenv(), ENV_leftisleft(), and ENV_marksquality().

#define YSTART cp       ( (cp) != NULL && ( (cp)[0] == 'y' || (cp)[0] == 'Y' ) )
 

Definition at line 22 of file afni_environ.h.


Function Documentation

void AFNI_mark_environ_done void   
 

Definition at line 74 of file afni_environ.c.

References afni_env_done.

Referenced by main().

00074 { afni_env_done = 1 ; return ; }

int AFNI_noenv char *   
 

Definition at line 164 of file afni_environ.c.

References my_getenv(), and NOISH.

Referenced by AFNI_brick_to_mri(), AFNI_force_adoption(), AFNI_plugin_button(), AFNI_serverlog(), AFNI_set_viewpoint(), AFNI_setup_viewing(), AFNI_start_version_check(), AFNI_startup_timeout_CB(), AFNI_time_index_CB(), ISQ_setup_ppmto_filters(), main(), MAIN_workprocess(), MCW_popup_message(), mri_brainormalize(), mri_read3D_analyze75(), mri_read_analyze75(), mri_warp3d_align_one(), read_glt_matrix(), THD_init_session(), THD_load_minc(), and THD_open_analyze().

00165 {
00166    char *ept ;
00167    if( ename == NULL ) return 0 ;
00168    ept = my_getenv(ename) ;
00169    return NOISH(ept) ;
00170 }

double AFNI_numenv char *   
 

Definition at line 174 of file afni_environ.c.

References my_getenv(), and strtod().

Referenced by AFNI_bucket_label_CB(), AFNI_init_niml(), GRA_handle_keypress(), ISQ_drawing_EV(), ISQ_handle_keypress(), ISQ_process_mri(), main(), PLUTO_scatterplot(), refit_MCW_optmenu(), and THD_get_all_timeseries().

00175 {
00176    char *ept,*ccc ; double val ;
00177    if( ename == NULL ) return 0.0l ;
00178    ept = my_getenv(ename) ;
00179    if( ept   == NULL ) return 0.0l ;
00180    val = strtod(ept,&ccc) ;
00181         if( *ccc == 'k' || *ccc == 'K' ) val *= 1024.0l ;
00182    else if( *ccc == 'm' || *ccc == 'M' ) val *= 1024.0l*1024.0l ;
00183    else if( *ccc == 'g' || *ccc == 'G' ) val *= 1024.0l*1024.0l*1024.0l ;
00184    return val ;
00185 }

void AFNI_process_environ char *   
 

Definition at line 86 of file afni_environ.c.

References afni_env_done, AFNI_suck_file(), ENTRY, free, getenv(), GETEQN, GETSTR, ISTARRED, left, malloc, nr, NSBUF, right, and THD_filename_pure().

Referenced by main(), my_getenv(), and SUMA_process_environ().

00087 {
00088    int   nbuf , nused , ii ;
00089    char *fbuf , *fptr ;
00090    char str[NSBUF] , left[NSBUF] , middle[NSBUF] , right[NSBUF] ;
00091 
00092 ENTRY("AFNI_process_environ") ;
00093    if( fname != NULL ){
00094       strcpy(str,fname) ;
00095    } else {
00096       char *home ;
00097       if( afni_env_done ) EXRETURN ;
00098       home = getenv("HOME") ;
00099       if( home != NULL ){ strcpy(str,home) ; strcat(str,"/.afnirc") ; }
00100       else              { strcpy(str,".afnirc") ; }
00101       afni_env_done = 1 ;
00102    }
00103 
00104    fbuf = AFNI_suck_file( str ) ; if( fbuf == NULL ) EXRETURN ;
00105    nbuf = strlen(fbuf) ;          if( nbuf == 0    ) EXRETURN ;
00106 
00107    fptr = fbuf ; nused = 0 ;
00108 
00109    /** scan for section strings, which start with "***" **/
00110 
00111    str[0] = '\0' ;  /* initialize string */
00112 
00113    while( nused < nbuf ){
00114 
00115       /**----------------------------------------**/
00116       /**-- skip ahead to next section keyword --**/
00117 
00118       SkipSection: while( ! ISTARRED(str) ){ GETSTR; }
00119 
00120       /*- 04 Jun 1999 -*/
00121 
00122       if( strcmp(str,"***END") == 0 ) break ;  /* exit main loop */
00123 
00124       if( strcmp(str,"***ENVIRONMENT") != 0 ){ GETSTR ; goto SkipSection ; }
00125 
00126       /**---------------------------------------**/
00127       /**-- ENVIRONMENT section [04 Jun 1999] --**/
00128 
00129       if( strcmp(str,"***ENVIRONMENT") == 0 ){  /* loop, looking for environment settings */
00130          char *enveqn ; int nl , nr ;
00131 
00132          while(1){                          /* loop, looking for 'name = value' */
00133             GETEQN ;
00134 
00135             if( !THD_filename_pure(left) ) continue ;
00136 
00137             nl = strlen(left) ; nr = strlen(right) ;
00138             enveqn = (char *) malloc(nl+nr+4) ;
00139             strcpy(enveqn,left) ; strcat(enveqn,"=") ; strcat(enveqn,right) ;
00140             putenv(enveqn) ;
00141          }
00142 
00143          continue ;  /* to end of outer while */
00144       } /* end of ENVIRONMENT */
00145 
00146    }  /* end of while loop */
00147 
00148  done:
00149    free(fbuf) ; EXRETURN ;
00150 }

int AFNI_setenv char *    cmd
 

Input is "name value". Return is 0 if OK, -1 if not OK.

Definition at line 190 of file afni_environ.c.

References eqn(), and free.

Referenced by AFNI_parse_args(), and main().

00191 {
00192    char nam[256]="\0" , val[1024]="\0" , eqn[1280] , *eee ;
00193 
00194    if( cmd == NULL || strlen(cmd) < 3 ) return(-1) ;
00195 
00196    sscanf( cmd , "%255s %1023s" , nam , val ) ;
00197    if( nam[0] == '\0' || val[0] == '\0' && strchr(cmd,'=') != NULL ){
00198      char *ccc = strdup(cmd) ;
00199      eee = strchr(ccc,'=') ; *eee = ' ' ;
00200      sscanf( ccc , "%255s %1023s" , nam , val ) ;
00201      free((void *)ccc) ;
00202    }
00203    if( nam[0] == '\0' || val[0] == '\0' ) return(-1) ;
00204 
00205    sprintf(eqn,"%s=%s",nam,val) ;
00206    eee = strdup(eqn) ; putenv(eee) ;
00207    return(0) ;
00208 }

char* AFNI_suck_file char *   
 

Definition at line 15 of file afni_environ.c.

References close(), fd, free, malloc, read(), and THD_filesize().

Referenced by AFNI_finalize_read_palette_CB(), AFNI_process_environ(), AFNI_process_setup(), AFNI_startup_layout_CB(), AFNI_startup_script_CB(), DRAW_finalize_dset_CB(), DRAW_label_getfile(), main(), RCREND_read_states(), REND_read_states(), and SUMA_AFNI_Extract_Colors().

00016 {
00017    int len , fd , ii ;
00018    char *buf ;
00019 
00020    if( fname == NULL || fname[0] == '\0' ) return NULL ;
00021 
00022    len = THD_filesize( fname ) ;
00023    if( len <= 0 ) return NULL ;
00024 
00025    fd = open( fname , O_RDONLY ) ;
00026    if( fd < 0 ) return NULL ;
00027 
00028    buf = (char *) malloc( sizeof(char) * (len+4) ) ;
00029    ii  = read( fd , buf , len ) ;
00030    close( fd ) ;
00031    if( ii <= 0 ){ free(buf) ; return NULL; }
00032 
00033    buf[len] = '\0' ;  /* 27 July 1998: 'len' used to be 'ii+1', which is bad */
00034    return buf ;
00035 }

int AFNI_yesenv char *    ename
 

-- ENVIRONMENT section [04 Jun 1999] --*

Definition at line 154 of file afni_environ.c.

References my_getenv(), and YESSISH.

Referenced by AFNI_brick_to_mri(), AFNI_func_overlay(), AFNI_init_niml(), AFNI_logger(), AFNI_make_widgets(), AFNI_newfunc_overlay(), AFNI_overlay(), AFNI_parse_args(), AFNI_range_setter(), AFNI_startup_timeout_CB(), AFNI_time_index_CB(), AFNI_view_xyz_CB(), calculate_results(), DRAW_main(), ENV_globalrange(), GRA_mapmenu_CB(), ISQ_but_disp_CB(), ISQ_drawing_EV(), ISQ_save_jpeg(), ISQ_saver_CB(), ISQ_setup_ppmto_filters(), ISQ_show_image(), machdep(), main(), MAIN_workprocess(), MCW_alter_widget_cursor(), mri_automask_image(), mri_brainormalize(), mri_dup2D(), mri_psinv(), mri_read3D_analyze75(), mri_read_analyze75(), mri_read_file(), mri_read_file_delay(), mri_read_mpeg(), mri_rgba_composite_array(), mri_write_analyze(), nifti_set_afni_extension(), read_input_data(), report_evaluation(), RWC_visibilize_CB(), T3D_swap_CB(), THD_force_malloc_type(), THD_init_one_datablock(), THD_load_datablock(), THD_load_nifti(), THD_normalize_flist(), THD_open_1D(), THD_open_analyze(), THD_open_minc(), THD_write_1D(), THD_write_atr(), THD_write_datablock(), TTRR_setup_widgets(), and XSAVE_output().

00155 {
00156    char *ept ;
00157    if( ename == NULL ) return 0 ;
00158    ept = my_getenv(ename) ;
00159    return YESSISH(ept) ;
00160 }

char* my_getenv char *   
 

Definition at line 76 of file afni_environ.c.

References afni_env_done, AFNI_process_environ(), and getenv().

Referenced by AFNI_fimmer_compute(), AFNI_new_fim_menu(), AFNI_noenv(), AFNI_numenv(), AFNI_startup_layout_CB(), AFNI_yesenv(), conv_set_ref(), CORREL_main(), GRA_fim_CB(), init_MCW_sizes(), init_TRUST_list(), initialize_program(), ISQ_reset_dimen(), main(), MCW_register_hint(), mri_3dalign_edging_default(), mri_warp3D_align_edging_default(), NLFIT_get_many_MODELs(), NOTES_make_widgets(), open_MCW_imseq(), PCOR_get_pcor(), PLOT_matrix_gray(), PLOT_tsgray(), PLUG_read_plugin(), RWC_getname(), T3D_check_outliers(), T3D_initialize_user_data(), THD_enviro_write_compression(), THD_enviro_write_order(), THD_get_many_timeseries(), THD_getpathprogs(), THD_init_session(), THD_open_3dcalc(), THD_open_nifti(), THD_rota_envpad(), THD_write_3dim_dataset(), TT_load_atlas(), VL_command_line(), and winsor21_box_func().

00077 {
00078    if( !afni_env_done ){
00079       char * sysenv = getenv("AFNI_SYSTEM_AFNIRC") ;       /* 16 Apr 2000 */
00080       if( sysenv != NULL ) AFNI_process_environ(sysenv) ;  /* 16 Apr 2000 */
00081       AFNI_process_environ(NULL) ;
00082    }
00083    return getenv( ename ) ;
00084 }
 

Powered by Plone

This site conforms to the following standards: