Doxygen Source Code Documentation
afni_friends.c File Reference
#include <stdlib.h>#include <time.h>#include <stdio.h>Go to the source code of this file.
| Data Structures | |
| struct | AFNI_friend | 
| struct | mday | 
| Defines | |
| #define | YOU_KNOW_WHAT 10 | 
| #define | INSPIRATION 5 | 
| #define | KLOSEK 0 | 
| #define | NUM_HELPTYPES (sizeof(afni_helptypes)/sizeof(char *)) | 
| #define | NUM_FRIENDS (sizeof(afni_friends)/sizeof(AFNI_friend)) | 
| #define | JAN 1 | 
| #define | FEB 2 | 
| #define | MAR 3 | 
| #define | APR 4 | 
| #define | MAY 5 | 
| #define | JUN 6 | 
| #define | JUL 7 | 
| #define | AUG 8 | 
| #define | SEP 9 | 
| #define | OCT 10 | 
| #define | NOV 11 | 
| #define | DEC 12 | 
| #define | NTMAX 9 | 
| Functions | |
| char * | AFNI_get_friend (void) | 
| char * | AFNI_get_date_trivia (void) | 
| Variables | |
| char * | afni_helptypes [] | 
| AFNI_friend | afni_friends [] | 
| mday | holiday [] | 
Define Documentation
| 
 | 
| 
 Definition at line 109 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 113 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 117 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 107 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 25 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
| 
 | 
| 
 Definition at line 106 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 112 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 111 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 26 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
| 
 | 
| 
 Definition at line 108 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 110 of file afni_friends.c. | 
| 
 | 
| 
 Definition at line 116 of file afni_friends.c. Referenced by AFNI_get_date_trivia(). | 
| 
 | 
| max # trivia elements allowed per date Definition at line 126 of file afni_friends.c. Referenced by AFNI_get_date_trivia(). | 
| 
 | 
| 
 Definition at line 82 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
| 
 | 
| 
 Definition at line 28 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
| 
 | 
| 
 Definition at line 115 of file afni_friends.c. Referenced by AFNI_get_date_trivia(). | 
| 
 | 
| 
 Definition at line 114 of file afni_friends.c. Referenced by AFNI_get_date_trivia(). | 
| 
 | 
| 
 Definition at line 24 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
Function Documentation
| 
 | 
| Return today's date trivia string. Definition at line 719 of file afni_friends.c. References mday::day, mday::label, mday::mon, NOV, NTMAX, OCT, SEP, and tt. Referenced by SPLASH_imseq_getim(). 
 00720 {
00721    time_t tt ;
00722    struct tm *lt ;
00723    int ii , ntar ;
00724    char *tar[NTMAX] ;
00725 
00726    tt = time(NULL) ;         /* seconds since 01 Jan 1970 */
00727    lt = localtime( &tt ) ;   /* break into pieces */
00728 
00729    /**** find this month and day in the trivia list, if present ****/
00730 
00731    for( ii=ntar=0 ; ntar < NTMAX && holiday[ii].day != 0 ; ii++ )
00732      if( holiday[ii].mon == lt->tm_mon+1 && holiday[ii].day == lt->tm_mday )
00733        tar[ntar++] = holiday[ii].label ;
00734 
00735    /**** Special days not on fixed dates ****/
00736 
00737    /* Day of month = 13 and weekday = Friday */
00738 
00739    if( ntar < NTMAX && lt->tm_mday == 13 && lt->tm_wday == 5 )
00740       tar[ntar++] = "Friday the 13th" ;
00741 
00742    /* 1st Monday in September */
00743 
00744    if( ntar < NTMAX && lt->tm_mon+1 == SEP && lt->tm_wday == 1 && lt->tm_mday <= 7 )
00745       tar[ntar++] = "Labor Day (USA)" ;
00746 
00747    /* 4th Thursday in November */
00748 
00749    if( ntar < NTMAX && lt->tm_mon+1 == NOV && lt->tm_wday == 4 &&
00750                        lt->tm_mday <= 28 && lt->tm_mday >= 22 )
00751       tar[ntar++] = "Thanksgiving (USA)" ;
00752 
00753    /* 1st Monday in October */
00754 
00755    if( ntar < NTMAX && lt->tm_mon+1 == OCT && lt->tm_wday == 1 && lt->tm_mday <= 7 )
00756       tar[ntar++] = "Opening of Supreme Court (USA)" ;
00757 
00758    /* 1st Tuesday after 1st Monday in November */
00759 
00760    if( ntar < NTMAX && lt->tm_mon+1 == NOV && lt->tm_wday == 2 &&
00761                        lt->tm_mday >= 2 && lt->tm_mday <= 8 )
00762       tar[ntar++] = "Election Day (USA)" ;
00763 
00764    /**** select which one to return ***/
00765 
00766    if( ntar == 1 ){
00767      return tar[0] ;
00768    } else if( ntar > 1 ){
00769      static int iold=-1 ;
00770      ii = (lrand48()>>8) % ntar ;
00771      if( ii == iold ) ii = (ii+1)%ntar ;
00772      iold = ii ; return tar[ii] ;
00773    }
00774 
00775    /* default trivia */
00776 
00777    return "[Elen sila lumenn' omentielvo]" ;
00778 }
 | 
| 
 | 
| Return a "thanks" string (static storage - don't free it). Definition at line 87 of file afni_friends.c. References afni_helptypes, AFNI_friend::helpmask, INSPIRATION, KLOSEK, name, NUM_FRIENDS, NUM_HELPTYPES, and YOU_KNOW_WHAT. Referenced by main(), and SPLASH_imseq_getim(). 
 00088 {
00089    static char buf[256] ; int nf , nh , hmask , qq=0 ;
00090    nf = lrand48() % NUM_FRIENDS ;
00091    do{
00092      nh = lrand48() % NUM_HELPTYPES ; hmask = 1 << nh ; qq++ ;
00093    } while( qq < 73 && (hmask & afni_friends[nf].helpmask) == 0 ) ;
00094 
00095    if( nh == YOU_KNOW_WHAT && nf != KLOSEK ) nh = INSPIRATION; /* only Gosia */
00096 
00097    sprintf( buf  ,
00098             "Thanks go to %s for %s" ,
00099             afni_friends[nf].name , afni_helptypes[nh] ) ;
00100    return buf ;
00101 }
 | 
Variable Documentation
| 
 | 
| Who we might thank. Definition at line 34 of file afni_friends.c. | 
| 
 | 
| Initial value:  {
   "advice and help"                ,  
   "much encouragement"             ,  
   "many suggestions"               ,  
   "useful feedback"                ,  
   "\"quick\" questions"            ,  
   "inspiration"                    ,  
   "great efforts"                  ,  
   "caloric input"                  ,  
   "awe-inspiring beer consumption" ,  
   "awe-inspiring caffeine binging" ,  
   "you-know-what"                     
}Definition at line 8 of file afni_friends.c. Referenced by AFNI_get_friend(). | 
| 
 | 
| The date trivia array. Definition at line 130 of file afni_friends.c. | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  