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

 

strt2symb

#include "sflsymb.h"
SYMTAB *
strt2symb (
    char **table)

Synopsis

Converts a table of strings into a symbol table. The input table consists of an array of null-terminated strings, terminated in a null pointer. Ignores any strings that don't look like: "name=value". If the table contains multiple strings with the same name, the last instance is stored in the symbol table. Note that if you omit the last null pointer in the input table, you will probably get an addressing error. Returns NULL if there was insufficient memory to allocate the symbol table, or if the input argument was null.

Source Code - (sflsymb.c)

{
    SYMTAB
        *symtab;                        /*  Allocated symbol table           */
    char
        *equals;                        /*  Position of '=' in string        */
    int
        string_nbr;                     /*  Index into string table          */

    if (!table)
        return (NULL);                  /*  Return NULL if argument is null  */

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

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