Doxygen Source Code Documentation
thd_dsetinslist.c
Go to the documentation of this file.00001 /***************************************************************************** 00002 Major portions of this software are copyrighted by the Medical College 00003 of Wisconsin, 1994-2000, and are released under the Gnu General Public 00004 License, Version 2. See the file README.Copyright for details. 00005 ******************************************************************************/ 00006 00007 #include "mrilib.h" 00008 #include "thd.h" 00009 00010 00011 /*----------------------------------------------------------------- 00012 find a dataset with a given name in a bunch of sessions, 00013 with the indicated session getting first priority 00014 -------------------------------------------------------------------*/ 00015 00016 THD_slist_find THD_dset_in_sessionlist( int find_type , void * target , 00017 THD_sessionlist * ssl , int iss ) 00018 { 00019 int jss ; 00020 THD_slist_find find ; 00021 00022 /*-- sanity check --*/ 00023 00024 if( ! ISVALID_SESSIONLIST(ssl) || ssl->num_sess <= 0 ){ 00025 BADFIND(find) ; return find ; 00026 } 00027 00028 /* search session # iss first */ 00029 00030 if( iss >=0 && iss < ssl->num_sess ){ 00031 find = THD_dset_in_session( find_type,target , ssl->ssar[iss] ) ; 00032 if( find.dset != NULL ){ find.sess_index = iss ; return find ; } 00033 } 00034 00035 /* search everybody else */ 00036 00037 for( jss=0 ; jss < ssl->num_sess ; jss++ ){ 00038 if( jss == iss ) continue ; 00039 find = THD_dset_in_session( find_type,target , ssl->ssar[jss] ) ; 00040 if( find.dset != NULL ){ find.sess_index = jss ; return find ; } 00041 } 00042 00043 return find ; 00044 }