148754Sbostic /*- 2*62317Sbostic * Copyright (c) 1988, 1993 3*62317Sbostic * The Regents of the University of California. All rights reserved. 431890Sminshall * 548754Sbostic * %sccs.include.redist.c% 631890Sminshall */ 731890Sminshall 834888Sbostic #ifndef lint 9*62317Sbostic static char sccsid[] = "@(#)astosc.c 8.1 (Berkeley) 06/06/93"; 1034888Sbostic #endif /* not lint */ 1134888Sbostic 1231245Sminshall #include <ctype.h> 1331245Sminshall 1431245Sminshall #include "../general/general.h" 1531245Sminshall 1631245Sminshall #include "../ctlr/function.h" 1731245Sminshall 1831240Sminshall #include "astosc.h" 1931240Sminshall 2031240Sminshall struct astosc astosc[256] = { 2131240Sminshall #include "astosc.out" 2231240Sminshall }; 2331240Sminshall 2431245Sminshall /* compare two strings, ignoring case */ 2531240Sminshall 2631245Sminshall static ustrcmp(string1,string2)2731245Sminshallustrcmp(string1, string2) 2831245Sminshall register char *string1; 2931245Sminshall register char *string2; 3031245Sminshall { 3131245Sminshall register int c1, c2; 3231245Sminshall 3331245Sminshall while ((c1 = (unsigned char) *string1++) != 0) { 3431245Sminshall if (isupper(c1)) { 3531245Sminshall c1 = tolower(c1); 3631245Sminshall } 3731245Sminshall if (isupper(c2 = (unsigned char) *string2++)) { 3831245Sminshall c2 = tolower(c2); 3931245Sminshall } 4031245Sminshall if (c1 < c2) { 4131245Sminshall return(-1); 4231245Sminshall } else if (c1 > c2) { 4331245Sminshall return(1); 4431245Sminshall } 4531245Sminshall } 4631245Sminshall if (*string2) { 4731245Sminshall return(-1); 4831245Sminshall } else { 4931245Sminshall return(0); 5031245Sminshall } 5131245Sminshall } 5231245Sminshall 5331245Sminshall 5431240Sminshall /* 5531240Sminshall * This routine takes a string and returns an integer. It may return 5631606Sminshall * -1 if there is no other integer which corresponds to the 5731606Sminshall * string. -1 implies an error. 5831240Sminshall */ 5931240Sminshall 6031240Sminshall int ascii_to_index(string)6131240Sminshallascii_to_index(string) 6231240Sminshall register char *string; 6331240Sminshall { 6431240Sminshall register struct astosc *this; 6531240Sminshall 6631240Sminshall for (this = astosc; this <= &astosc[highestof(astosc)]; this++) { 6731800Sminshall if ((this->name != 0) && (ustrcmp(this->name, string) == 0)) { 6831240Sminshall return this-astosc; 6931240Sminshall } 7031240Sminshall } 7131606Sminshall return -1; 7231240Sminshall } 73