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

 

env2symb

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

Synopsis

Creates a symbol table containing the processes environment variables. Each variable is stored as a name plus value. The names of the variables are converted to upper case prior to being put into the symbol table. 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-2000 iMatix Corporation