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_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

#define APR   4
 

Definition at line 109 of file afni_friends.c.

#define AUG   8
 

Definition at line 113 of file afni_friends.c.

#define DEC   12
 

Definition at line 117 of file afni_friends.c.

#define FEB   2
 

Definition at line 107 of file afni_friends.c.

#define INSPIRATION   5
 

Definition at line 25 of file afni_friends.c.

Referenced by AFNI_get_friend().

#define JAN   1
 

Definition at line 106 of file afni_friends.c.

#define JUL   7
 

Definition at line 112 of file afni_friends.c.

#define JUN   6
 

Definition at line 111 of file afni_friends.c.

#define KLOSEK   0
 

Definition at line 26 of file afni_friends.c.

Referenced by AFNI_get_friend().

#define MAR   3
 

Definition at line 108 of file afni_friends.c.

#define MAY   5
 

Definition at line 110 of file afni_friends.c.

#define NOV   11
 

Definition at line 116 of file afni_friends.c.

Referenced by AFNI_get_date_trivia().

#define NTMAX   9
 

max # trivia elements allowed per date

Definition at line 126 of file afni_friends.c.

Referenced by AFNI_get_date_trivia().

#define NUM_FRIENDS   (sizeof(afni_friends)/sizeof(AFNI_friend))
 

Definition at line 82 of file afni_friends.c.

Referenced by AFNI_get_friend().

#define NUM_HELPTYPES   (sizeof(afni_helptypes)/sizeof(char *))
 

Definition at line 28 of file afni_friends.c.

Referenced by AFNI_get_friend().

#define OCT   10
 

Definition at line 115 of file afni_friends.c.

Referenced by AFNI_get_date_trivia().

#define SEP   9
 

Definition at line 114 of file afni_friends.c.

Referenced by AFNI_get_date_trivia().

#define YOU_KNOW_WHAT   10
 

Definition at line 24 of file afni_friends.c.

Referenced by AFNI_get_friend().


Function Documentation

char* AFNI_get_date_trivia void   
 

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 }

char* AFNI_get_friend void   
 

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

AFNI_friend afni_friends[] [static]
 

Who we might thank.

Definition at line 34 of file afni_friends.c.

char* afni_helptypes[] [static]
 

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"                     
}
What we might thank people for.

Definition at line 8 of file afni_friends.c.

Referenced by AFNI_get_friend().

mday holiday[] [static]
 

The date trivia array.

Definition at line 130 of file afni_friends.c.

 

Powered by Plone

This site conforms to the following standards: