Annotation of coherent/d/conf/tboot/pacifier.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * pacifier.c - state machine for putting something interesting on the screen.
                      3:  */
                      4: #include "tboot.h"
                      5: #include "pac_states.h"
                      6: 
                      7: int slow_flag = FALSE;         /* Slow down pacifier.  */
                      8: int feet_flag = FALSE;         /* Print footprints?  */
                      9: 
                     10: void pac_init();               /* Initialise the state machine.  */
                     11: void pac_cleanup();            /* Clean up after the state machine.  */
                     12: void pacifier();               /* Run the next step of the state machine.  */
                     13: void subliminal();     /* Print a subliminal message.  */
                     14: 
                     15: static int pac_inited = FALSE; /* Has pac_init() been called?  */
                     16: static int pac_dirty = FALSE;  /* Has pacifier() been called?  */
                     17: static int state;
                     18: static int substate;
                     19: static int count;
                     20: 
                     21: void
                     22: pacifier()
                     23: {
                     24:        pac_dirty = TRUE;
                     25: 
                     26:        if (!pac_inited) {
                     27:                pac_init();
                     28:        }
                     29: 
                     30:        switch (state) {
                     31:        case FORWARD:
                     32:                switch (substate) {
                     33:                case N_S:
                     34:                        FOOTPRINT;
                     35:                        puts("|\010");
                     36:                        substate = NE_SW;
                     37:                        break;
                     38:                case NE_SW:
                     39:                        FOOTPRINT;
                     40:                        puts("/\010");
                     41:                        substate = E_W;
                     42:                        break;
                     43:                case E_W:
                     44:                        FOOTPRINT;
                     45:                        puts("-\010");
                     46:                        substate = NW_SE;
                     47:                        break;
                     48:                case NW_SE:
                     49:                        FOOTPRINT;
                     50:                        puts("\\\010");
                     51:                        substate = NE_SW;
                     52:                        break;
                     53:                default:
                     54:                        puts("pacifier(): Illegal substate.\r\n");
                     55:                        pac_init();
                     56:                        break;
                     57:                } /* switch (substate) */
                     58: 
                     59:                if (++count > THRESHOLD) {
                     60: #if 0
                     61:                        subliminal("Buy COHware!");
                     62: #endif
                     63:                        puts(" \010\010");
                     64:                        state = REVERSE;
                     65:                        count = 0;
                     66:                }
                     67:                if (slow_flag) {
                     68:                        wait_for_keystroke(2, -1);      /* Brief pause.  */
                     69:                }
                     70:                break;  
                     71:        case REVERSE:
                     72:                switch (substate) {
                     73:                case N_S:
                     74:                        UNFOOTPRINT;
                     75:                        puts("|\010");
                     76:                        substate = NW_SE;
                     77:                        break;
                     78:                case NW_SE:
                     79:                        UNFOOTPRINT;
                     80:                        puts("\\\010");
                     81:                        substate = E_W;
                     82:                        break;
                     83:                case E_W:
                     84:                        UNFOOTPRINT;
                     85:                        puts("-\010");
                     86:                        substate = NE_SW;
                     87:                        break;
                     88:                case NE_SW:
                     89:                        UNFOOTPRINT;
                     90:                        puts("/\010");
                     91:                        substate = N_S;
                     92:                        break;
                     93:                default:
                     94:                        puts("pacifier(): Illegal substate.\r\n");
                     95:                        pac_init();
                     96:                        break;
                     97:                } /* switch (substate) */
                     98:                if (++count > THRESHOLD) {
                     99:                        puts("_\010");
                    100:                        state = FORWARD;
                    101:                        count = 0;
                    102:                }
                    103:                if (slow_flag) {
                    104:                        wait_for_keystroke(2, -1);      /* Brief pause.  */
                    105:                }
                    106:                break;
                    107:        default:
                    108:                puts("pacifier(): Illegal state.\r\n");
                    109:                pac_init();
                    110:                break;
                    111:        } /* switch (state) */
                    112: 
                    113: } /* pacifier() */
                    114: 
                    115: 
                    116: /*
                    117:  * Print a subliminal message on the console.
                    118:  * It does this by printing the message, backspacing over it,
                    119:  * spacing over it, and then backspacing again.
                    120:  */
                    121: void
                    122: subliminal(msg)
                    123: char *msg;
                    124: {
                    125:        int i, len;
                    126: 
                    127:        len = strlen(msg);
                    128:        puts(msg);
                    129: 
                    130:        for (i = len; i > 0; --i) {
                    131:                puts("\010");
                    132:        }
                    133: 
                    134:        if (slow_flag) {
                    135:                wait_for_keystrok(4, -1);       /* Brief pause.  */
                    136:        }
                    137: 
                    138:        for (i = len; i > 0; --i) {
                    139:                puts(" ");
                    140:        }
                    141: 
                    142:        for (i = len; i > 0; --i) {
                    143:                puts("\010");
                    144:        }
                    145: } /* subliminal() */
                    146: 
                    147: /*
                    148:  * Initialize the pacifier state machine.
                    149:  */
                    150: void
                    151: pac_init()
                    152: {
                    153:        pac_inited = TRUE;
                    154:        state = FORWARD;
                    155:        substate = N_S;
                    156:        count = 0;
                    157: } /* pac_init() */
                    158: 
                    159: 
                    160: /*
                    161:  * Clean up the screen after the pacifier.
                    162:  */
                    163: void
                    164: pac_cleanup()
                    165: {
                    166:        int i;
                    167: 
                    168:        if (pac_dirty) {
                    169:                puts("\r");
                    170:                for (i = THRESHOLD+1; i > 0; --i) {
                    171:                        puts(" ");
                    172:                }
                    173:                puts("\r");
                    174:        }
                    175:        pac_dirty = FALSE;
                    176: } /* pac_cleanup() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.