Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
thd_logafni.c
Go to the documentation of this file.00001 #include "niml.h"
00002
00003 #undef AFNI_SERVER
00004 #undef AFNI_REQUEST
00005
00006
00007
00008 #define AFNI_SERVER "tcp:afni.nimh.nih.gov:80"
00009
00010
00011
00012 #define AFNI_REQUEST "HEAD /AFNIlogpath HTTP/1.0\r\n" \
00013 "User-Agent: %s\r\n\r\n"
00014
00015
00016
00017
00018
00019
00020
00021 void AFNI_serverlog( char *str )
00022 {
00023 pid_t child_pid ;
00024 NI_stream ns ;
00025 int nbuf=0 , jj ;
00026 char *sbuf , *rbuf , *ss ;
00027
00028 if( str == NULL || *str == '\0' ) return ;
00029 if( AFNI_noenv("AFNI_VERSION_CHECK") ) return ;
00030
00031
00032
00033 child_pid = fork() ;
00034 if( child_pid != (pid_t)0 ) return ;
00035
00036
00037
00038
00039
00040 ns = NI_stream_open( AFNI_SERVER , "w" ) ;
00041 if( ns == (NI_stream)NULL ) _exit(0) ;
00042
00043
00044
00045 sbuf = strdup(str) ;
00046 for( ss=sbuf ; *ss != '\0' ; ss++ ) if( !isgraph(*ss) ) *ss = ' ' ;
00047
00048
00049
00050 nbuf = strlen(sbuf) ;
00051 for( ss=sbuf+(nbuf-1) ; isspace(*ss) ; ss-- ) *ss = '\0' ;
00052
00053
00054
00055 nbuf = strlen(sbuf)+strlen(AFNI_REQUEST)+32 ;
00056 rbuf = (char *)malloc(nbuf) ;
00057 sprintf(rbuf,AFNI_REQUEST,sbuf) ;
00058
00059
00060
00061 jj = NI_stream_writecheck( ns , 1234 ) ;
00062 if( jj < 1 ) _exit(0) ;
00063
00064
00065
00066 NI_stream_write( ns , rbuf , strlen(rbuf) ) ;
00067
00068
00069
00070 NI_sleep(1) ; NI_stream_closenow(ns) ; _exit(0) ;
00071 }