|
|
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 the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)astosc.c 4.1 (Berkeley) 12/4/88";
20: #endif /* not lint */
21:
22: #include <ctype.h>
23:
24: #include "../general/general.h"
25:
26: #include "../ctlr/function.h"
27:
28: #include "astosc.h"
29:
30: struct astosc astosc[256] = {
31: #include "astosc.out"
32: };
33:
34: /* compare two strings, ignoring case */
35:
36: static
37: ustrcmp(string1, string2)
38: register char *string1;
39: register char *string2;
40: {
41: register int c1, c2;
42:
43: while ((c1 = (unsigned char) *string1++) != 0) {
44: if (isupper(c1)) {
45: c1 = tolower(c1);
46: }
47: if (isupper(c2 = (unsigned char) *string2++)) {
48: c2 = tolower(c2);
49: }
50: if (c1 < c2) {
51: return(-1);
52: } else if (c1 > c2) {
53: return(1);
54: }
55: }
56: if (*string2) {
57: return(-1);
58: } else {
59: return(0);
60: }
61: }
62:
63:
64: /*
65: * This routine takes a string and returns an integer. It may return
66: * -1 if there is no other integer which corresponds to the
67: * string. -1 implies an error.
68: */
69:
70: int
71: ascii_to_index(string)
72: register char *string;
73: {
74: register struct astosc *this;
75:
76: for (this = astosc; this <= &astosc[highestof(astosc)]; this++) {
77: if ((this->name != 0) && (ustrcmp(this->name, string) == 0)) {
78: return this-astosc;
79: }
80: }
81: return -1;
82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.