| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

sym_get_value

#include "sflsymb.h"
char *
sym_get_value (
    const SYMTAB *table,                /*  Symbol table to process          */
    const char *name,                   /*  Name of symbol to look for       */
    const char *default_value)          /*  Value to return if not defined   */

Synopsis

Returns value for specified symbol, if defined in table, or a default value otherwise. You can use this in situations where a symbol does not need to exist, and where frequent look-up by name is required. The symbol table must exist and be populated beforehand as appropriate. Returns a pointer to the value; you should never write to this string since it may exist as a string constant, not writable memory.

Examples

    value = sym_get_value (env, "PATH", NULL);
    if (!value)
        puts ("PATH not defined");

Source Code - (sflsymb.c)

{
    SYMBOL
        *symbol;                        /*  Search through symbol table      */

    ASSERT (table);
    symbol = sym lookup symbol (table, name);
    if (symbol)
        return (symbol-> value);
    else
        return ((char *) default_value);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation