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  

niccc.c

Go to the documentation of this file.
00001 #include "niml.h"
00002 
00003 /*--- Debug printout of a NIML element. ---*/
00004 
00005 void NIML_to_stderr( void *nini )
00006 {
00007    NI_stream ns_err ;
00008    ns_err = NI_stream_open( "stderr:" , "w" ) ;
00009    if( ns_err != NULL ){
00010      NI_write_element( ns_err , nini , NI_TEXT_MODE | NI_HEADERSHARP_FLAG ) ;
00011      NI_stream_close( ns_err ) ;
00012    }
00013 }
00014 
00015 /*--- Open a NIML stream, read elements from it, print them ---*/
00016 
00017 int main( int argc , char *argv[] )
00018 {
00019    NI_stream ns ;
00020    void *nini ;
00021    int nn ;
00022 
00023    if( argc < 2 ){
00024       fprintf(stderr,"Usage: niccc streamspec\n");exit(0);
00025    }
00026 
00027    ns = NI_stream_open( argv[1], "r" ) ;
00028    if( ns == NULL ){
00029       fprintf(stderr,"*** niccc: NI_stream_open fails\n") ; exit(1) ;
00030    }
00031    while(1){
00032      nn = NI_stream_goodcheck( ns , 1 ) ;
00033      if( nn < 0 ){
00034        fprintf(stderr,"\n*** niccc: Stream fails\n"); exit(1);
00035      }
00036      if( nn == 0 ){ NI_sleep(5); continue; }  /* waiting for Godot */
00037 
00038      nn = NI_stream_readcheck( ns , 1 ) ;     /* check for data */
00039 
00040      if( nn > 0 ){
00041        nini = NI_read_element( ns , 2 ) ;
00042        if( nini == NULL ){
00043          fprintf(stderr,"*** niccc: read returns NULL\n");
00044        } else {
00045          NIML_to_stderr( nini ) ;
00046          NI_free_element( nini ) ;
00047        }
00048      }
00049    }
00050 }
 

Powered by Plone

This site conforms to the following standards: