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

 

env2symb

#include "sflenv.h"
SYMTAB *
env2symb (void)

Synopsis

Creates a symbol table containing the environment variables. Each variable is stored as a name plus value. You can destroy the symbol table using sym delete table() when you are finished with it.

Source Code - (sflenv.c)

{
    SYMTAB
        *symtab;                        /*  Allocated symbol table           */
    char
        *next_entry,                    /*  Environment variable + value     */
        *equals;                        /*  Position of '=' in string        */
    int
        string_nbr;                     /*  Index into string table          */

    /*  We create the table here, instead of passing through strt2symb(),
        since we have to ensure that environment variable names are stored
        in uppercase.  Some systems (NT) return mixed-case names.            */

    symtab = sym create table ();
    if (symtab)
      {
        for (string_nbr = 0; environ [string_nbr]; string_nbr++)
          {
            next_entry = mem_strdup (environ [string_nbr]);
            equals = strchr (next_entry, '=');
            if (equals)
              {
                *equals = '\0';         /*  Cut into two strings             */
                strupc (next_entry);
                sym assume symbol (symtab, next_entry, equals + 1);
              }
            mem_free (next_entry);
          }
      }
    return (symtab);
}

| << | < | > | >> iMatix Copyright © 1996-98 iMatix