Annotation of coherent/b/STREAMS/conf_79/stune.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *-IMPORTS:
                      3:  *     <sys/compat.h>
                      4:  *             CONST
                      5:  *             USE_PROTO
                      6:  *             ARGS ()
                      7:  *     <stdlib.h>
                      8:  *             NULL
                      9:  *             malloc ()
                     10:  *             free ()
                     11:  */
                     12: 
                     13: #include <sys/compat.h>
                     14: #include <stdlib.h>
                     15: 
                     16: #include "ehand.h"
                     17: #include "symbol.h"
                     18: #include "read.h"
                     19: #include "mtune.h"
                     20: 
                     21: #include "stune.h"
                     22: 
                     23: LOCAL stune_t *        _stunes;
                     24: 
                     25: 
                     26: /*
                     27:  * Read lines from an "stune" file.
                     28:  */
                     29: 
                     30: #ifdef USE_PROTO
                     31: LOCAL int (read_stune) (input_t * input, lex_t * lexp)
                     32: #else
                     33: LOCAL int
                     34: read_stune ARGS ((input, lexp))
                     35: input_t              * input;
                     36: lex_t        * lexp;
                     37: #endif
                     38: {
                     39:        int             ch = '\n';
                     40:        stune_t       * stunep;
                     41:        ehand_t         err;
                     42: 
                     43:        if ((stunep = (stune_t *) malloc (sizeof (* stunep))) == NULL)
                     44:                throw_error ("out of memory in read_stune ()");
                     45: 
                     46:        if (PUSH_HANDLER (err) == 0) {
                     47:                /*
                     48:                 * If the first thing on the line works out to be an EOF,
                     49:                 * then bail out without an error.
                     50:                 */
                     51: 
                     52:                ch = read_symbol (input, lexp, & stunep->st_name);
                     53: 
                     54:                if (stunep->st_name == NULL) {
                     55:                        /*
                     56:                         * We allow an EOF at the beginning of a line and we
                     57:                         * also allow a blank line.
                     58:                         */
                     59: 
                     60:                        goto at_eof;
                     61:                }
                     62:                check_not_eol (ch);
                     63: 
                     64:                if ((stunep->st_mtune = find_mtune (stunep->st_name)) == NULL)
                     65:                        throw_error ("Parameter name not in 'mtune' file");
                     66: 
                     67:                if (stunep->st_mtune->mt_stune != NULL)
                     68:                        throw_error ("Two values configured for parameter");
                     69: 
                     70:                /*
                     71:                 * Pull in the parameter value
                     72:                 */
                     73: 
                     74:                ch = read_longs (input, lexp, & stunep->st_value, NO_RANGE);
                     75: 
                     76:                if (stunep->st_value < stunep->st_mtune->mt_min ||
                     77:                    stunep->st_value > stunep->st_mtune->mt_max)
                     78:                        throw_error ("Parameter value outside configurable range");
                     79: 
                     80:                ch = expect_eol (input, lexp, ch);
                     81: 
                     82:                /*
                     83:                 * Having passed all the reasonableness checks, we link the
                     84:                 * new entry into the chain.
                     85:                 */
                     86: 
                     87:                stunep->st_mtune->mt_stune = stunep;
                     88: 
                     89:                stunep->st_next = _stunes;
                     90:                _stunes = stunep;
                     91:        } else {
                     92: 
                     93:                free (stunep);
                     94:                CHAIN_ERROR (err);
                     95:        }
                     96: 
                     97: at_eof:
                     98:        POP_HANDLER (err);
                     99:        return ch;
                    100: }
                    101: 
                    102: 
                    103: #if 0
                    104: /*
                    105:  * Regenerate an 'stune' line from the stored record.
                    106:  */
                    107: 
                    108: #ifdef USE_PROTO
                    109: void (write_stune) (stune_t * stunep, FILE * out)
                    110: #else
                    111: void
                    112: write_stune ARGS ((stunep, out))
                    113: stune_t              * stunep;
                    114: FILE         * out;
                    115: #endif
                    116: {
                    117:        (void) fprintf (out, "%-8s %-7ld\n",
                    118:                        stunep->st_name->s_data,
                    119:                        stunep->st_value);
                    120: }
                    121: #endif
                    122: 
                    123: 
                    124: /*
                    125:  * Suck in a complete 'stune' file.
                    126:  */
                    127: 
                    128: #ifdef USE_PROTO
                    129: void (read_stune_file) (CONST char * name)
                    130: #else
                    131: void
                    132: read_stune_file ARGS ((name))
                    133: CONST char    *        name;
                    134: #endif
                    135: {
                    136:        read_dev_file (name, read_stune);
                    137: }

unix.superglobalmegacorp.com

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