|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that this notice is preserved and that due credit is given ! 7: * to the University of California at Berkeley. The name of the University ! 8: * may not be used to endorse or promote products derived from this ! 9: * software without specific prior written permission. This software ! 10: * is provided ``as is'' without express or implied warranty. ! 11: * ! 12: * @(#)astosc.c 3.2 (Berkeley) 3/28/88 ! 13: */ ! 14: ! 15: #include <ctype.h> ! 16: ! 17: #include "../general/general.h" ! 18: ! 19: #include "../ctlr/function.h" ! 20: ! 21: #include "astosc.h" ! 22: ! 23: struct astosc astosc[256] = { ! 24: #include "astosc.out" ! 25: }; ! 26: ! 27: /* compare two strings, ignoring case */ ! 28: ! 29: static ! 30: ustrcmp(string1, string2) ! 31: register char *string1; ! 32: register char *string2; ! 33: { ! 34: register int c1, c2; ! 35: ! 36: while ((c1 = (unsigned char) *string1++) != 0) { ! 37: if (isupper(c1)) { ! 38: c1 = tolower(c1); ! 39: } ! 40: if (isupper(c2 = (unsigned char) *string2++)) { ! 41: c2 = tolower(c2); ! 42: } ! 43: if (c1 < c2) { ! 44: return(-1); ! 45: } else if (c1 > c2) { ! 46: return(1); ! 47: } ! 48: } ! 49: if (*string2) { ! 50: return(-1); ! 51: } else { ! 52: return(0); ! 53: } ! 54: } ! 55: ! 56: ! 57: /* ! 58: * This routine takes a string and returns an integer. It may return ! 59: * -1 if there is no other integer which corresponds to the ! 60: * string. -1 implies an error. ! 61: */ ! 62: ! 63: int ! 64: ascii_to_index(string) ! 65: register char *string; ! 66: { ! 67: register struct astosc *this; ! 68: ! 69: for (this = astosc; this <= &astosc[highestof(astosc)]; this++) { ! 70: if ((this->name != 0) && (ustrcmp(this->name, string) == 0)) { ! 71: return this-astosc; ! 72: } ! 73: } ! 74: return -1; ! 75: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.