// 更改用户的权限设定 unsigned int setperms(unsigned int pbits, char *prompt, int numbers, int (*showfunc) ()) { int lastperm = numbers - 1; int i, done = NA; char choice[3], buf[80]; screen_move(4, 0); screen_printf("\033[m请按下您要的代码来设定%s,按 Enter 结束.\n", prompt); screen_move(6, 0); screen_clrtobot(); for (int j = 0; j < 16 && j < numbers; ++j) { showfunc(pbits, j, false); if (j + 16 < numbers) { tui_repeat_char(' ', 4); showfunc(pbits, j + 16, false); } } while (!done) { //% sprintf(buf, "选择(ENTER 结束%s): ", sprintf(buf, "\xd1\xa1\xd4\xf1(ENTER \xbd\xe1\xca\xf8%s): ", //% ((strcmp(prompt, "权限") != 0)) ? "" : ",0 停权"); ((strcmp(prompt, "\xc8\xa8\xcf\xde") != 0)) ? "" : "\xa3\xac""0 \xcd\xa3\xc8\xa8"); getdata(-1, 0, buf, choice, 2, DOECHO, YEA); *choice = toupper(*choice); /* if (*choice == '0') return (0); else modified by kit,rem 0停权* remed all by Amigo 2002.04.03*/ if (*choice == '\n' || *choice == '\0') done = YEA; else if (*choice < 'A' || *choice> 'A' + lastperm) bell (); else { i = *choice - 'A'; pbits ^= (1 << i); if ((*showfunc) (pbits, i, YEA) == NA) { pbits ^= (1 << i); } //if } //else } //while !done return (pbits); }
static void consume(int search_item, char *prompt, int (*showfunc)()) { int i; while (1) { if ((i = whatitem( prompt )) == '\33') return; if (i != '.' && i != '-') { if (i == '*') { i = showfunc(); cursors(); } if (i && i != '.') { switch (iven[i-'a']) { case OSCROLL: if ( search_item != OSCROLL ) { lprintf("\nYou can't %s that.", prompt ); return; } read_scroll( ivenarg[i-'a'] ); break; case OBOOK: if ( search_item != OSCROLL ) { lprintf("\nYou can't %s that.", prompt ); return; } readbook( ivenarg[i-'a'] ); break; case OCOOKIE: if ( search_item != OCOOKIE ) { lprintf("\nYou can't %s that.", prompt ); return; } outfortune(); break; case OPOTION: if ( search_item != OPOTION ) { lprintf("\nYou can't %s that.", prompt ); return; } quaffpotion( ivenarg[i-'a'], TRUE ); break; case 0: ydhi(i); return; default: lprintf("\nYou can't %s that.", prompt ); return; } iven[i-'a'] = 0; return; } } } }