void Ident() { int rc; char name[9]; char buf[256]; TPB tpb; getchoice(0, " Ident ", "Identification tape", NULL, NULL, NULL, NULL); TapeStill ts("/dev/ravt0"); rc = ts.Ident(); endmesg(); if (rc != TSOK) { getchoice(0, " Ident ", "Error identification.", NULL, NULL, NULL, NULL); getchar(); endmesg(); return; } ts.GetTape(&tpb); bzero(name, sizeof(name)); switch(tpb.format) { case FORMAT_K4: case FORMAT_K7: case FORMAT_K7CRC: case FORMAT_RS: strncpy(name, tpb.name, 8); } getchoice(0, " Ident ", name, NULL, NULL, NULL, NULL); // printf("Format:\t%02X\n", tpb.format); getchar(); endmesg(); };
void main() { int ch,ch1,ch2,ch3; fm=fopen("member.dat","a+"); ft=fopen("trans.dat","a+"); fb=fopen("book.dat","a+"); mainscr(); while(1) { bk: showmenu(mainmenu,5,10,35); ch=getchoice(mainmenu,"MBRHE",10,35,5); switch(ch) { case 1:bk1: showmenu(memmenu,4,10,35); ch1=getchoice(memmenu,"ARIB",10,35,4); switch(ch1) { case 1: addmember(); goto bk1; case 2: renewmem(); goto bk1; case 3: memdupid(); goto bk1; case 4: goto bk; } break; case 2:bk2: showmenu(bookmenu,4,10,35); ch2=getchoice(bookmenu,"AIRB",10,35,4); switch(ch2) { case 1: addbook(); goto bk2; case 2: issbook(); goto bk2; case 3: retbook(); goto bk2; case 4: goto bk; } break; case 3:bk3: showmenu(rptmenu,4,10,35); ch3=getchoice(rptmenu,"MBTB",10,35,4); switch(ch3) { case 1: allmem(); goto bk3; case 2: allbook();goto bk3; case 3: alltransac();goto bk3; case 4: goto bk; } break; case 4: showhelp(); break; case 5:fclose(ft); fclose(fm); fclose(fb); exit(); } } }
int main() { int choice = 0; FILE *input; FILE *output; struct termios initial_settings, new_settings; if (!isatty(fileno(stdout))) { fprintf(stderr, "You are not a terminal, OK.\n"); } input = fopen("/dev/tty", "r"); output = fopen("/dev/tty", "w"); if (!input || !output) { fprintf(stderr, "Unable to open /dev/tty\n"); exit(1); } tcgetattr(fileno(input), &initial_settings); new_settings = initial_settings; new_settings.c_lflag &= ~ICANON; new_settings.c_lflag &= ~ECHO; new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; new_settings.c_lflag &= ~ISIG; if (tcsetattr(fileno(input), TCSANOW, &new_settings) != 0) { fprintf(stderr, "could not set attributes\n"); } do { choice = getchoice("Please select an action", menu, input, output); printf("You have chosen: %c\n", choice); } while (choice != 'q'); tcsetattr(fileno(input), TCSANOW, &initial_settings); exit(0); }
int main() { int choice = 0; FILE *input; FILE *output; struct termios initial_settings,new_settings; // 後面變更設定使用 if(!isatty(fileno(stdout))){ fprintf(stderr,"You are not a terminal!\n"); exit(1); } input=fopen("/dev/tty","r"); // 表示input 指向鍵盤 output=fopen("/dev/tty","w"); // 表示output 指向鍵盤 if(!input || !output){ fprintf(stderr,"Unable to open /dev/tty\n"); exit(1); } // 這邊開始使用變更終端機設定來解決此問題 tcgetattr(fileno(input),&initial_settings); new_settings=initial_settings; new_settings.c_lflag &= ~ICANON; // 關閉標準輸入功能 new_settings.c_cc[VMIN]=1; // 至少一個字元 new_settings.c_cc[VTIME]=0; //等待時間0秒 new_settings.c_lflag &= ~ISIG; // 關閉訊號功能 if(tcsetattr(fileno(input),TCSANOW,&new_settings)!=0){ fprintf(stderr,"Could not set attributes\n"); } do { choice = getchoice("Please select an action", menu,input,output); printf("You have chosen: %c\n", choice); } while (choice != 'q'); exit(0); }
void init_batch() { register i, ret; char *header = "Выбор задания"; # ifdef VERBOSE if (! saved_batch && loaded_batch) { i = getchoice (1, " Предупреждение ", "Задание не сохранено", "Сохранять задание ?", " Нет ", " Да ", " Возврат "); switch (i) { case 1: save_batch (); break; case -1: case 2: return; } } # endif ret = small_menu (header, batch_name, batch_n); if (ret >= 0) { for (i = 0; i < MAX_BATCH; i++) batch_w[i].l[0] = batch_w[i].l[1] = 0; batch_n = batch_w[0].i[0] = ret; inited_batch = 1, loaded_batch = 0, saved_batch = 1; change_batch (); } }
int main() { int choice; initscr(); do { choice = getchoice("Options:", current_cd[0] ? extended_menu : main_menu); switch(choice) { case 'q': break; case 'a': add_record(); break; case 'c': count_cds(); break; case 'f': find_cd(); break; case 'l': list_tracks(); break; case 'r': remove_cd(); break; case 'u': update_cd(); break; } } while(choice != 'q'); endwin(); exit(EXIT_SUCCESS); }
int main() { int choice = 0; FILE *input; FILE *output; if(!isatty(fileno(stdout))){ fprintf(stderr, "You are not a termial~!!\n"); } input = fopen("/dev/tty", "r"); output = fopen("/dev/tty", "w"); if(!input | !output){ fprintf(stderr, "Unable to open /dev/tty\n"); exit(1); } do{ choice = getchoice("Please select an action", menu, input, output); printf("You have chosen: %c\n", choice); }while(choice != 'q'); exit(0); }
int main(void) { int choice = 0; FILE *input; FILE *output; if(!isatty(fileno(stdout))) { /* see how isatty and fileno functions are used*/ fprintf(stderr, "you are not terminal:\n"); exit(1); } input = fopen("/dev/tty", "r"); output = fopen("/dev/tty", "w"); /*checking the availability of terminal*/ if(!input || !output) { fprintf(stderr, "Unable to open /dev/tty\n"); exit(1); } do { choice = getchoice("Please select an action\n", menu, input, output); printf("you have chosen %c\n", choice); } while(choice != 'q'); exit(0); }
int main() { int choice; initscr(); do { choice = getchoice("Options:", current_cd[0] ? extended_menu : main_menu); switch (choice) { case 'q': break; case 'a': add_record(); break; case 'c': count_cds(); break; case 'f': find_cd(); break; case 'l': break; case 'u': break; } } while (choice != 'q'); endwin(); exit(0); }
void advance_book(char* student_id) { char* adbook_menu[] = { "cCheck free computers", "iInput slot details", "bBack", 0, }; int choice; char* name; name = fscan(student_id,'n'); initscr(); do{ choice= getchoice(name,adbook_menu); switch(choice) { case 'b': break; case 'c': check_status(student_id); break; case 'i': clear_login_screen(student_id); adv_book(student_id); break; } } while(choice!='b'); endwin(); }
//main screen function void login_screen(char* student_id) { int choice; char* name; name= "fscan(student_id,'n')"; initscr(); do{ choice= getchoice("name",login_menu); switch(choice) { case 'l': break; case 'b': clear_login_screen(student_id); inst_book(student_id); break; case 'a': clear_login_screen(student_id); advance_book(student_id); break; case 'c': clear_login_screen(student_id); change_pswd(student_id); break; } } while(choice!='l'); endwin(); }
int main(){ int choice = 0; do { choice = getchoice("Please select an action", menu); printf("You've chosen: %c\n", choice); }while(choice != 'q'); exit(0); }
/****************usage*****************/ int main() { int choice = 0; do { choice = getchoice(¡°Please select an action¡±, menu); printf(¡°You have chosen: %c\n¡±, choice); } while(choice != ¡®q¡¯); exit(0); }
int main() { int res; showmenu(); while ((res = getchoice(1, 4)) != 4) printf("I like choice %d.\n", res); printf("Bye!\n"); return 0; }
void error (char *s, ...) { char buf [100]; va_list ap; va_start (ap, s); vsprintf (buf, s, ap); va_end (ap); getchoice (1, " Error ", buf, 0, " Ok ", 0, 0); }
void message (char *name, char *s, ...) { char buf [100]; va_list ap; va_start (ap, s); vsprintf (buf, s, ap); va_end (ap); getchoice (0, name, buf, 0, 0, 0, 0); }
static void makeup_menu(char *text,char *env,char *cmdline) { int i; parse_options(env); for(i=0;i<=envs_local;i++) { menu_edit_items[i].y=POP_Y+i; menu_edit_items[i].x=POP_X; menu_edit_items[i].dnext=i+1; menu_edit_items[i].rnext=i+1; if(i==0)menu_edit_items[i].msg=text; else menu_edit_items[i].msg=envp_local[i-1]; menu_edit_items[i].arg=0; menu_edit_items[i].action=0; if(i<=envs_local && strstr(envp_local[i-1],"=[")) { menu_edit_items[i].type=TYPE_CHOICE; menu_edit_items[i].arg=envp_local[i-1]=malloc(strlen(menu_edit_items[i].msg)); strcpy(envp_local[i-1],menu_edit_items[i].msg); strcpy(strchr(envp_local[i-1],'=')+1,getchoice(menu_edit_items[i].msg,1)); } else menu_edit_items[i].type=TYPE_NONE; } for(i=envs_local+1;cmdline;i++) { char *p,*p1; int len; p=cmdline; menu_edit_items[i].msg=p; p1=strchr(p,'=')+1; cmdline=strstr(cmdline,";;"); if(cmdline)cmdline+=2; len=cmdline?cmdline-p1-2:strlen(p1); p=menu_edit_items[i].arg=malloc(len+1); strncpy(p,p1,len); p[len]=0; menu_edit_items[i].y=POP_Y+i; menu_edit_items[i].x=POP_X; menu_edit_items[i].dnext=i+1; menu_edit_items[i].rnext=i+1; menu_edit_items[i].type=TYPE_NONE; menu_edit_items[i].action=menu[item].action; } items_edit=i; menu_edit_items[0].dnext=envs_local+1; menu_edit_items[0].action=editmenu_action; menu_edit_items[i].y=POP_Y+i; menu_edit_items[i].x=POP_X; menu_edit_items[i].dnext=1; menu_edit_items[i].rnext=1; menu_edit_items[items_edit].action=quit_edit; menu_edit_items[items_edit].msg="quit"; menu_edit_items[items_edit+1].msg=0; }
/* menu */ void setshellname (void) { switch (getchoice (0, " Shell ", "Select which shell to use:", NULL, " Shell ", " Cshell ", NULL)) { case 0: usecshell = 0; break; case 1: usecshell = 1; break; } }
/* main, menu */ void mydelete (void) { char buf [80]; register struct file *p; register c; if (c = tagged ()) { /* delete group of files */ sprintf (buf, "You have selected %d file%s.", c, c>1 ? "s" : ""); if (getchoice (0, " Delete ", buf, NULL, " Delete ", " Cancel ", NULL)) return; sprintf (buf, "You are DELETING %d selected file%s from", c, c>1 ? "s" : ""); if (getchoice (1, " Delete ", buf, cur->d.cwd, " Ok ", " Cancel ", NULL)) return; for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p) if (p->tag && unlink (p->name) < 0) error ("Cannot delete %s", p->name); } else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) { /* delete directory */ if (getchoice (0, " Delete ", "Do you wish to delete directory", p->name, " Delete ", " Cancel ", NULL)) return; if (runl(1, "/bin/rmdir", "rmdir", p->name, NULL)) { error ("Cannot delete directory %s", p->name); return; } } else if (c == S_IFREG) { /* delete regular file */ if (getchoice (0, " Delete ", "Do you wish to delete", p->name, " Delete ", " Cancel ", NULL)) return; if (unlink (p->name) < 0) { error ("Cannot delete %s", p->name); return; } } setdir (cur == left ? right : left, NULL); setdir (cur, NULL); }
ctrl3 () { win0 (); if (getchoice (1, " ОР ", "Остановить процессор ?", NULL, " Да ", " Нет ", NULL) == 0) { stop (); halting = 1; win0 (); } curwin = 0; prmenu (); }
ctrl4 () { win0 (); if (getchoice (1, " АР ", "Пустить процессор ?", NULL, " Да ", " Нет ", NULL) == 0) { run (); halting = 0; win0 (); } curwin = 0; prmenu (); }
int main(int argc, char *argv[]) { int choice = 0; while (choice != 'q') { choice = getchoice("Please make a choice:", menu); printf("You have chosen: %c\n", choice); } return 0; }
ctrl2 () { win0 (); if (getchoice (1, " У0 ", "Обнулить процессор ?", NULL, " Да ", " Нет ", NULL) == 0) { zero (); halting = 1; win0 (); } curwin = 0; prmenu (); }
static int edit_digital(int msg) { char *p; if(ischoice(menu[item].msg)) { p=getchoice(menu[item].msg,msg-'0'); if(p)strcpy(strchr(envp_local[item-1],'=')+1,p); __cprint(menu[item].y,menu[item].x,popwidth,0x70,envp_local[item-1]); } return 1; }
ctrl1 () { win0 (); if (getchoice (1, " У0ио ", "Обнулить процессор и игнорировать остановы ?", NULL, " Да ", " Нет ", NULL) == 0) { send (0, 0363); zero (); halting = 1; win0 (); } curwin = 0; prmenu (); }
ctrl5 () { win0 (); if (getchoice (1, " ПктАр ", "Пустить процессор с команды на РКП ?", NULL, " Да ", " Нет ", NULL) == 0) { setcrp (); run (); halting = 0; win0 (); } curwin = 0; prmenu (); }
int main() { int choice = 0; if (!isatty(fileno(stdout))) { fprintf(stderr, "You are not a terminal!\n"); exit(1); } do { choice = getchoice("Please select an action", menu); printf("You have chosen: %c\n", choice); } while(choice != 'q'); exit(0); }
/* menu */ void menuedit (void) { char buf [80]; switch (getchoice (0, " Menu Edit ", "Select which menu to edit:", NULL, " Current menu ", " Home menu ", NULL)) { case 0: editfnam (".menu"); break; case 1: strcpy (buf, home); strcat (buf, "/.menu"); editfnam (buf); break; } }
void load_batch() { register char *s; FILE *fi; if (is_name > 1) goto do_load; # ifdef VERBOSE if (! saved_batch && loaded_batch) { int i; i = getchoice (1, " Предупреждение ", "Задание не сохранено", "Сохранять задание ?", " Нет ", " Да ", " Возврат "); switch (i) { case 1: save_batch (); break; case -1: case 2: return; } } # endif if ((s = getstring(NAME_LENGTH, batch_file, "Загрузка задания", "Введите имя файла с заданием для САС")) != NULL) { strncpy (batch_file, s, NAME_LENGTH); if (extension (batch_file, "sas") != NULL) { do_load : if ((fi = fopen (batch_file, "r")) == NULL) { error ("%s : %s", batch_file, sys_errlist[errno]); return; } if ((batch_n = getw(fi)) == EOF || fread (batch_w[0].c, sizeof (batch_w[0].c), MAX_BATCH, fi) != MAX_BATCH) { error ("%s : %s", batch_file, sys_errlist[errno]); } if (fclose (fi) == EOF) { error ("%s : %s", batch_file, sys_errlist[errno]); return; } inited_batch = 0, loaded_batch = saved_batch = 1; big_menu (0); } } }
/* menu */ void seteditname (void) { register char *p; switch (getchoice (0, " Edit ", "Select which editor to use for F4:", NULL, " Built-in ", " External ", NULL)) { case 0: useredit = 0; default: return; case 1: break; } if (! (p = getstring (40, editname, " Edit ", "Editor to use"))) return; strncpy (editname, p, 40); editname [39] = 0; useredit = 1; }