| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#include "sflsymb.h" SYMTAB * strt2symb ( char **table)
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.
{ 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); }
| << | < | > | >> |
![]() |