int main (int argc, char *argv []) { char *alloc, dest [128], *table [10] = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", NULL }, **new_table; DESCR *descr; int index, string; Bool result; puts ("Testing xstrcpy():"); xstrcpy (dest, "This ", "Is ", "A ", "String", NULL); puts (dest); puts ("Testing xstrcpy():"); alloc = xstrcpy (NULL, "This ", "Is ", "A ", "String", NULL); puts (alloc); puts ("Testing xstrcat():"); xstrcat (dest, "1", "2", "3", NULL); puts (dest); puts ("Testing strt2descr():"); descr = strt2descr (table); printf ("Descriptor size=%ld\n", (long) descr-> size); new_table = descr2strt (descr); printf ("Contents of table: "); for (string = 0; new_table [string]; string++) printf ("[%s] ", new_table [string]); puts (""); printf ("Testing soundex():\n"); for (index = 0; index < NAME_TABLE_SIZE; index++) { alloc = soundex (surname [index]); printf ("%20s -> %5s %s\n", surname [index], alloc, streq (alloc, soundex_value [index])? "OK": "FAIL"); } printf ("Testing match_pattern():\n\n"); printf ("%-20s %-20s %-10s = %-10s => %s\n", "String", "Pattern", "Check case", "Result", "Test"); printf ("---------------------------------------------------------------" \ "----------\n"); index = 0; while (pattern_table [index].string) { result = match_pattern (pattern_table [index].string, pattern_table [index].pattern, pattern_table [index].ignore_case); printf ("%-20s %-20s %-10s = %-10s => %s\n", pattern_table [index].string, pattern_table [index].pattern, pattern_table [index].ignore_case? "No": "Yes", result? "Ok": "Fail", (result == pattern_table [index].result)? "Ok": "Fail"); index++; } return (EXIT_SUCCESS); }
DESCR * env2descr (void) { return (strt2descr (environ)); }