2 * IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
4 * tubttyaid.c -- Linemode Attention-ID functionality
10 * Author: Richard Hitt
16 #define PF9_STR "\033j"
17 #define PF10_STR "\033k"
18 #define PF11_STR "\033j"
19 /* other AID-key default strings */
23 /* C1 = PF13 */ { TA_DOSTRING, 0 },
24 /* C2 = PF14 */ { TA_DOSTRING, 0 },
25 /* C3 = PF15 */ { TA_DOSTRING, 0 },
26 /* C4 = PF16 */ { TA_DOSTRING, 0 },
27 /* C5 = PF17 */ { TA_DOSTRING, 0 },
28 /* C6 = PF18 */ { TA_DOSTRING, 0 },
29 /* C7 = PF19 */ { TA_DOSTRING, 0 },
30 /* C8 = PF20 */ { TA_DOSTRING, 0 },
31 /* C9 = PF21 */ { TA_DOSTRING, 0 },
32 /* 4A = PF22 */ { TA_DOSTRING, 0 },
33 /* 4B = PF23 */ { TA_DOSTRING, 0 },
34 /* 4C = PF24 */ { TA_DOSTRING, 0 },
54 /* 60 = NoAID */ { 0, 0 },
60 /* E6 = OpRdr */ { 0, 0 },
61 /* E7 = MSRdr */ { 0, 0 },
62 /* E8 = NoAID */ { 0, 0 },
65 /* 6B = PA3 */ { TA_SHORTREAD, 0 },
66 /* 6C = PA1 */ { TA_SHORTREAD | TA_DOSTRING, PA1_STR },
67 /* 6D = CLEAR */ { TA_SHORTREAD | TA_CLEARKEY, 0 },
68 /* 6E = PA2 */ { TA_SHORTREAD | TA_CLEARLOG, 0 },
70 /* F0 = TstRq */ { 0, 0 },
71 /* F1 = PF1 */ { TA_DOSTRING, 0 },
72 /* F2 = PF2 */ { TA_DOSTRING, 0 },
73 /* F3 = PF3 */ { TA_DOSTRING, PF3_STR },
74 /* F4 = PF4 */ { TA_DOSTRING, 0 },
75 /* F5 = PF5 */ { TA_DOSTRING, 0 },
76 /* F6 = PF6 */ { TA_DOSTRING, 0 },
77 /* F7 = PF7 */ { TA_DOSTRING, 0 },
78 /* F8 = PF8 */ { TA_DOSTRING, 0 },
79 /* F9 = PF9 */ { TA_DOSTRING, PF9_STR },
80 /* 7A = PF10 */ { TA_DOSTRING, PF10_STR },
81 /* 7B = PF11 */ { TA_DOSTRING, PF11_STR },
82 /* 7C = PF12 */ { TA_DOSTRING, 0 },
83 /* 7D = ENTER */ { TA_DOENTER, 0 },
84 /* 7E = Pen */ { 0, 0 },
89 tty3270_aid_init(tub_t *tubp)
91 memcpy(tubp->tty_aid, aidtab, sizeof aidtab);
92 tubp->tty_aidinit = 1;
97 tty3270_aid_fini(tub_t *tubp)
102 if (tubp->tty_aidinit == 0)
104 for (i = 0; i < 64; i++) {
105 if ((sp = tubp->tty_aid[i].string) == NULL)
107 if (sp == aidtab[i].string)
111 tubp->tty_aidinit = 0;
115 tty3270_aid_reinit(tub_t *tubp)
117 tty3270_aid_fini(tubp);
118 tty3270_aid_init(tubp);
122 tty3270_aid_get(tub_t *tubp, int aid, int *aidflags, char **aidstring)
126 ap = AIDENTRY(aid, tubp);
128 *aidstring = ap->string;
133 * tty3270_aid_set() -- write_proc extension
134 * Parse written string as an AID name. Return 0 if it's not.
135 * Otherwise absorb the string and return count or -error.
138 tty3270_aid_set(tub_t *tubp, char *buf, int count)
147 if (tubp->tty_aidinit == 0)
149 if (count < 3) /* If AID-key name too short */
151 name[0] = buf[0] < 0x60? buf[0]: (buf[0] & 0x5f);
152 name[1] = buf[1] < 0x60? buf[1]: (buf[1] & 0x5f);
153 if (name[0] == 'P' && name[1] == 'F') {
154 aidn = simple_strtoul(buf+2, &sp, 10);
155 if (aidn < 1 || aidn > 24)
157 aidx = aidn > 12? aidn - 12: aidn + 0x30;
158 ap = &tubp->tty_aid[aidx];
159 } else if (name[0] == 'P' && name[1] == 'A') {
160 aidn = simple_strtoul(buf+2, &sp, 10);
161 if (aidn < 1 || aidn > 3)
164 case 1: aidx = 0x2c; break;
165 case 2: aidx = 0x2e; break;
166 case 3: aidx = 0x2b; break;
167 default: aidx = 0; break;
169 ap = &tubp->tty_aid[aidx];
175 tubp->tty_showaidx = ap - tubp->tty_aid;
177 } else if (*sp == '=') {
180 if (ap->string != NULL &&
181 ap->string != aidtab[aidx].string)
183 ap->string = aidtab[aidx].string;
184 ap->aid = aidtab[aidx].aid;
187 if ((pfp = kmalloc(len + 1, GFP_KERNEL)) == NULL)
189 if (ap->string != NULL &&
190 ap->string != aidtab[aidx].string)
192 if (sp[len - 1] == '\n') {
193 ap->aid = TA_DOSTRING;
197 ap->aid = TA_DOSTRINGD;
199 memcpy(pfp, sp, len + 1);