int b_notes_edit() { char buf[STRLEN], buf2[STRLEN]; char ans[4]; int aborted; int notetype; if (!chkBM(currbp, ¤tuser)) return 0; clear(); move(1, 0); prints("�༭/ɾ������¼"); //ѯ�ʱ༭���ֱ���¼ while (1) { getdata(3, 0, "�༭��ɾ������������ (0) �뿪 (1) һ�㱸��¼ (2) ���ܱ���¼? [1] ", ans, 2, DOECHO, YEA); if (ans[0] == '0') return FULLUPDATE; if (ans[0] == '\0') strcpy(ans, "1"); if (ans[0] == '1' || ans[0] == '2') break; } makevdir(currboard); //��������¼Ŀ¼ if (ans[0] == '2') { setvfile(buf, currboard, "secnotes"); notetype = 2; } else { setvfile(buf, currboard, "notes"); notetype = 1; } sprintf(buf2, "(E)�༭ (D)ɾ�� %4s����¼? [E]: ", (notetype == 1) ? "һ��" : "����"); getdata(5, 0, buf2, ans, 2, DOECHO, YEA); //ѯ�ʱ༭����ɾ�� if (ans[0] == 'D' || ans[0] == 'd') { //ɾ������¼ move(6, 0); sprintf(buf2, "���Ҫɾ��%4s����¼", (notetype == 1) ? "һ��" : "����"); if (askyn(buf2, NA, NA)) { move(7, 0); prints("����¼�Ѿ�ɾ��...\n"); pressanykey(); unlink(buf); aborted = 1; } else aborted = -1; } else aborted = vedit(buf, NA, YEA); //�༭����¼ if (aborted == -1) { pressreturn(); } else { if (notetype == 1) setvfile(buf, currboard, "noterec"); else setvfile(buf, currboard, "notespasswd"); unlink(buf); } return FULLUPDATE; }
int more(char *fpath, int promptend) { extern char *strcasestr(); static char *head[4] = {"§@ªÌ", "¼ÐÃD", "®É¶¡", "Âà«H"}; char *ptr, *word, buf[1024], *ch1; struct stat st; FILE *fp; usint pagebreak[MAXPAGES], pageno, lino; int line, ch, viewed, pos, numbytes; int header = 0; int local = 0; char search_char0 = 0; static char search_str[81] = ""; typedef char *(*FPTR) (); static FPTR fptr; int searching = 0; int scrollup = 0; char *http[80] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; /* Ptt */ char pagemode = 0; char pagecount = 0; inmore = 1; memset(pagebreak, 0, sizeof(pagebreak)); if (*search_str) search_char0 = *search_str; *search_str = 0; if (!(fp = fopen(fpath, "r"))) { inmore = 0; return -1; } if (fstat(fileno(fp), &st)) { inmore = 0; fclose(fp); return -1; } pagebreak[0] = pageno = viewed = line = pos = 0; clear(); while ((numbytes = readln(fp, buf)) || (line == t_lines)) { if (scrollup) { rscroll(); move(0, 0); } if (numbytes) /* ¤@¯ë¸ê®Æ³B²z */ { if (!viewed) /* begin of file */ { if (showansi) /* header processing */ { if (!strncmp(buf, str_author1, LEN_AUTHOR1)) { line = 3; word = buf + LEN_AUTHOR1; local = 1; } else if (!strncmp(buf, str_author2, LEN_AUTHOR2)) { line = 4; word = buf + LEN_AUTHOR2; } while (pos < line) { if (!local) str_decode(word); if (!pos && ((ptr = strstr(word, str_post1)) || (ptr = strstr(word, str_post2)))) { ptr[-1] = '\0'; /* hialan §ïÃC¦â */ clrtoeol(); prints("[1;36m¢~\033[46;37m%s\033[m%-55.55s[1;33;46m%.4s[m\033[1;33m%-13s\033[36m¢¡[0m\n", head[0], word, ptr, ptr + 5); } else if (pos < (local ? 3 : 4)) { clrtoeol(); prints("[1;36m¢x\033[46;37m%s\033[m%-72.72s[1;36m¢x\033[m\n", head[pos], word); } viewed += numbytes; numbytes = readln(fp, buf); if (!pos && viewed >= 79) /* ²Ä¤@¦æ¤Óªø¤F */ { if (memcmp(buf, head[1], 2)) /* ²Ä¤G¦æ¤£¬O [¼Ð....] */ { viewed += numbytes; /* Ū¤U¤@¦æ¶i¨Ó³B²z */ numbytes = readln(fp, buf); } } pos++; } if (pos) { header = 1; outs("[1;36m¢¢¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w\033[0;30;47m y)¦^À³ /)·j´M¤å¦r =[]<>)¥DÃD¦¡¾\\Ū \033[0;1;36m¢£[m\n"); line = pos = (local ? 4 : 5); } } lino = pos; word = NULL; } /* ¡°³B²z¤Þ¥ÎªÌ & ¤Þ¨¥ */ if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>')) word = "[36m"; if ((buf[1] == ' ') && (buf[0] == ':' || buf[0] == '>') && (buf[2] == ':' || buf[2] == '>')) word = "[33m"; if ((buf[0] == '¡' && buf[1] == '°') || !strncmp(buf, "==>", 3)) word = "[1;36m"; ch1 = buf; while (1) /* Ptt */ { int i; char e, *ch2; if (ch2 = strstr(ch1, "gopher://")); else if (ch2 = strstr(ch1, "mailto:")); else if (ch2 = strstr(ch1, "board://")); /* ¤ä´©ª½±µ¶i¤J¬ÝªO */ else break; for (e = 0; ch2[e] != ' ' && ch2[e] != '\n' && ch2[e] != '\0' && ch2[e] != '"' && ch2[e] != ';' && ch2[e] != ']'; e++); for (i = 0; http[i] && i < 80; i++) if (!strncmp(http[i], ch2, e) && http[e] == 0) break; if (!http[i]) { http[i] = (char *)malloc(e + 1); strncpy(http[i], ch2, e); http[i][e] = 0; pagecount++; } ch1 = &ch2[7]; } if (word) outs(word); { char msg[500], *pos; if (*search_str && (pos = fptr(buf, search_str))) { char SearchStr[41]; char buf1[100], *pos1; strncpy(SearchStr, pos, strlen(search_str)); SearchStr[strlen(search_str)] = 0; searching = 0; sprintf(msg, "%.*s[7m%s[0m", pos - buf, buf, SearchStr); while (pos = fptr(pos1 = pos + strlen(search_str), search_str)) { sprintf(buf1, "%.*s[7m%s[0m", pos - pos1, pos1, SearchStr); strcat(msg, buf1); } strcat(msg, pos1); outs(Ptt_prints(msg, NO_RELOAD)); } else { outs(Ptt_prints(buf, NO_RELOAD)); } } if (word) { outs("[0m"); word = NULL; } outc('\n'); if (beep) { bell(); beep = 0; } if (line < b_lines) /* ¤@¯ë¸ê®ÆŪ¨ú */ line++; if (line == b_lines && searching == -1) { if (pageno > 0) fseek(fp, (off_t) (viewed = pagebreak[--pageno]), SEEK_SET); else searching = 0; lino = pos = line = 0; clear(); continue; } if (scrollup) { move(line = b_lines, 0); clrtoeol(); for (pos = 1; pos < b_lines; pos++) viewed += readln(fp, buf); } else if (pos == b_lines) /* ±²°Ê¿Ã¹õ */ scroll(); else pos++; if (!scrollup && ++lino >= b_lines && pageno < MAXPAGES - 1) { pagebreak[++pageno] = viewed; lino = 1; } if (scrollup) { lino = scrollup; scrollup = 0; } viewed += numbytes; /* ²ÖpŪ¹L¸ê®Æ */ } else line = b_lines; /* end of END */ if (promptend && (!searching && line == b_lines || viewed == st.st_size)) { move(b_lines, 0); if (viewed == st.st_size) { if (searching == 1) searching = 0; } else if (pageno == 1 && lino == 1) { if (searching == -1) searching = 0; } prints("%s ÂsÄý P.%d(%d%%) ", COLOR2, pageno, (viewed * 100) / st.st_size); prints("%s ¡ö¡ô¡õ¡÷|PgUp|PgDn|Home|End)¾ÉÄý h)»¡©ú \033[m", COLOR3); move(b_lines, 0); /* ¸Ñ¨Mª½±µ¸õ¨ì¬ÝªOªºBug */ while (line == b_lines || (line > 0 && viewed == st.st_size)) { switch (ch = igetkey()) { case 'h': case 'H': case '?': show_file("etc/help/MORE.help", 0, 24, ONLY_COLOR); pressanykey_old(NULL); if (pageno) pageno--; lino = line = 0; break; case ':': { char buf[10]; int i = 0; getdata(b_lines - 1, 0, "Goto Page: ", buf, 5, DOECHO, 0); sscanf(buf, "%d", &i); if (0 < i && i < MAXPAGES && (i == 1 || pagebreak[i - 1])) pageno = i - 1; else if (pageno) pageno--; lino = line = 0; break; } case '/': { char ans[4] = "n"; *search_str = search_char0; getdata(b_lines - 1, 0, "[·j´M]ÃöÁä¦r:", search_str, 40, DOECHO, 0); if (*search_str) { searching = 1; if (getdata(b_lines - 1, 0, "°Ï¤À¤j¤p¼g(Y/N/Q)? [N] ", ans, 4, LCECHO, 0) && *ans == 'y') fptr = strstr; else fptr = strcasestr; } if (*ans == 'q') searching = 0; if (pageno) pageno--; lino = line = 0; break; } case 'n': if (*search_str) { searching = 1; if (pageno) pageno--; lino = line = 0; } break; case 'N': if (*search_str) { searching = -1; if (pageno) pageno--; lino = line = 0; } break; case 'r': case 'R': case 'Y': case 'y': case 'A': case 'a': case 'F': case 'B': case KEY_LEFT: case 'q': case 'b': case 'f': case ']': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ case '[': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ case '=': /* Kaede ¬°¤F¥DÃD¾\Ū¤è«K */ fclose(fp); inmore = 0; return ch; case Ctrl('F'): case KEY_PGDN: line = 1; break; case 't': if (viewed == st.st_size) { /* ch ']' */ fclose(fp); inmore = 0; return ']'; } line = 1; break; case ' ': if (viewed == st.st_size) { /* ch 'f' */ fclose(fp); inmore = 0; return 'f'; } line = 1; break; case KEY_RIGHT: if (viewed == st.st_size) { /* ch 'q' */ fclose(fp); inmore = 0; return 'q'; } line = 1; pagemode = 0; break; case '\r': case '\n': if (pagemode) { more_web(http[pagemode - 1], YEA); /* pagebreak[0] = pageno = viewed = line = pos = 0; */ pagemode = 0; *search_str = 0; if (pageno) pageno--; lino = line = 0; break; } case KEY_DOWN: if (viewed == st.st_size || promptend == 2 && (ch == '\r' || ch == '\n')) { /* ch 'f' */ fclose(fp); inmore = 0; return 'f'; } line = t_lines - 2; break; case '$': case 'G': case KEY_END: line = t_lines; break; case '0': case 'g': case KEY_HOME: pageno = line = 0; break; case 'E': if (strcmp(fpath, "etc/ve.hlp")) { /* ch 'q' */ fclose(fp); inmore = 0; vedit(fpath, HAS_PERM(PERM_SYSOP) ? 0 : 2); return 'q'; } break; case KEY_ESC: if (KEY_ESC_arg == 'n') { edit_note(); if (pageno) pageno--; lino = line = 0; } else if (KEY_ESC_arg == 'c') capture_screen(); break; case Ctrl('I'): if (!pagecount) break; pagemode = (pagemode % pagecount) + 1; strcpy(search_str, http[pagemode - 1]); fptr = strstr; if (pageno) pageno--; lino = line = 0; break; case KEY_UP: line = -1; break; case Ctrl('B'): case KEY_PGUP: if (pageno > 1) { if (lino < 2) pageno -= 2; else pageno--; lino = line = 0; } else if (pageno && lino > 1) pageno = line = 0; break; case Ctrl('H'): if (pageno > 1) { if (lino < 2) pageno -= 2; else pageno--; lino = line = 0; } else if (pageno && lino > 1) pageno = line = 0; else { /* ch 'b' */ fclose(fp); inmore = 0; return 'b'; } } } if (line > 0) { move(b_lines, 0); clrtoeol(); refresh(); } else if (line < 0) { /* Line scroll up */ if (pageno <= 1) { if (lino == 1 || !pageno) { /* ch 'b' */ fclose(fp); inmore = 0; return 'b'; } /* ¶¤º¤W±² sheng 20020113 */ if (header && lino <= 6 - local) { fseek(fp, (off_t) (viewed = pagebreak[scrollup = lino = pageno = 0] = 0), SEEK_SET); clear(); } } if (pageno && lino > 1) { line = lino - 2; if (pageno == 1 && header) line = lino - 3; scrollup = lino - 1; fseek(fp, (off_t) (viewed = pagebreak[pageno - 1]), SEEK_SET); while (line--) viewed += readln(fp, buf); } else if (pageno > 1) { scrollup = b_lines - 1; line = b_lines - 2; if (pageno == 2 && header) line = b_lines - 3; fseek(fp, (off_t) (viewed = pagebreak[--pageno - 1]), SEEK_SET); while (line--) viewed += readln(fp, buf); } line = pos = 0; } else { pos = 0; fseek(fp, (off_t) (viewed = pagebreak[pageno]), SEEK_SET); clear(); } } } fclose(fp); if (promptend) { pressanykey(NULL); clear(); } else outs(reset_color); inmore = 0; return 'q'; /* ch 'q'*/ }
int b_notes_edit() { char buf[STRLEN], buf2[STRLEN]; char ans[4]; int aborted; int notetype; if (!chkBM(currbp, ¤tuser)) return 0; clear(); move(0, 0); prints("�趨��\n\n (1)һ�㱸��¼\n (2)���ܱ���¼\n"); prints(" (3)����ǰ��\n (4)�Ƿ�ǿ��ʹ��ǰ\n"); while (1) { getdata(7, 0,"��ǰѡ��[1](0~4): ", ans, 2, DOECHO, YEA); if (ans[0] == '0') return FULLUPDATE; if (ans[0] == '\0') strcpy(ans, "1"); if (ans[0] >= '1' && ans[0] <= '4' ) break; } makevdir(currboard); //��������¼Ŀ¼ notetype = ans[0] - '0'; if (notetype == 2) { setvfile(buf, currboard, "secnotes"); } else if (notetype == 3) { setvfile(buf, currboard, "prefix"); } else if (notetype == 1) { setvfile(buf, currboard, "notes"); } else if (notetype == 4 ) { int pos; struct boardheader fh; pos = search_record(BOARDS, &fh, sizeof(fh), cmpbnames, currboard); if (askyn("�Ƿ�ǿ��ʹ��ǰ��", (fh.flag & BOARD_PREFIX_FLAG)?YEA:NA,NA)) { fh.flag |= BOARD_PREFIX_FLAG; } else { fh.flag &= ~BOARD_PREFIX_FLAG; } substitute_record(BOARDS, &fh, sizeof(fh), pos); return FULLUPDATE; } sprintf(buf2, "(E)�༭ (D)ɾ�� %4s? [E]: ", (notetype == 3)?"����ǰ��":(notetype == 1) ? "һ�㱸��¼" : "���ܱ���¼"); getdata(8, 0, buf2, ans, 2, DOECHO, YEA); //ѯ�ʱ༭����ɾ�� if (ans[0] == 'D' || ans[0] == 'd') { //ɾ������¼ move(9, 0); sprintf(buf2, "���Ҫɾ��ô��"); if (askyn(buf2, NA, NA)) { move(10, 0); prints("�Ѿ�ɾ��...\n"); pressanykey(); unlink(buf); aborted = 1; } else aborted = -1; } else aborted = vedit(buf, NA, YEA); //�༭����¼ if (aborted == -1) { pressreturn(); } else { if (notetype == 1) setvfile(buf, currboard, "noterec"); else setvfile(buf, currboard, "notespasswd"); unlink(buf); } return FULLUPDATE; }
int x_love() { char buf1[200], save_title[TTLEN + 1]; char receiver[61], path[STRLEN] = "home/"; int x, y = 0, tline = 0, poem = 0; FILE *fp, *fpo; time_t timenow; struct tm *gtime; fileheader_t mhdr; setutmpmode(LOVE); time(&timenow); gtime = localtime(&timenow); sprintf(buf1,"%c/%s/love%d%d", cuser.userid[0], cuser.userid,gtime->tm_sec,gtime->tm_min); strcat(path,buf1); move(1,0); clrtobot(); outs("\n歡迎使用情書產生器 v0.00 版 \n"); outs("有何難以啟齒的話,交由系統幫你說吧.\n爸爸說 : 濫情不犯法.\n"); if(!getdata(7, 0, "收信人:", receiver, 60, DOECHO)) return 0; if(receiver[0] && !(searchuser(receiver) && getdata(8, 0, "主 題:", save_title, TTLEN, DOECHO))) { move(10, 0); outs("收信人或主題不正確, 情書無法傳遞. "); pressanykey(); return 0; } fpo = fopen(path, "w"); fprintf(fpo, "\n"); if((fp = fopen(DATA, "r"))) { while(fgets(buf1,100, fp)) { switch(buf1[0]) { case '#': break; case '@': if(!strncmp(buf1, "@begin", 6) || !strncmp(buf1, "@end", 4)) tline=3; else if(!strncmp(buf1,"@poem",5)) { poem = 1; tline = 1; fprintf(fpo, "\n\n"); } else tline=2; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': sscanf(buf1,"%d",&x); y = (rand() % (x - 1)) * tline; break; default: if(!poem) { if(y > 0) y = y - 1; else { if(tline > 0) { fprintf(fpo, "%s", buf1); tline--; } } } else { if(buf1[0] == '$') y--; else if(y == 0) fprintf(fpo,"%s",buf1); } } } fclose(fp); fclose(fpo); if(vedit(path, YEA, NULL) == -1) { unlink(path); clear(); outs("\n\n 放棄寄情書\n"); pressanykey(); return -2; } sethomepath(buf1, receiver); stampfile(buf1, &mhdr); Rename(path, buf1); strncpy(mhdr.title, save_title, TTLEN); strcpy(mhdr.owner, cuser.userid); mhdr.savemode = '\0'; sethomedir(path, receiver ); if(append_record(path, &mhdr, sizeof(mhdr)) == -1) return -1; hold_mail(buf1, receiver); return 1; } return 0; }
int deal_gopherkey(char ch, int allnum, int pagenum) { char fname[STRLEN], fpath[STRLEN]; #ifdef INTERNET_EMAIL struct shortfile fhdr; #endif switch (ch) { case 'h': case 'H': show_help("help/announcereadhelp"); g_refresh(); break; case 'E': case 'e': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { vedit(fname, NA, YEA); unlink(fname); g_refresh(); } show_message(NULL); break; case '=': { tmpitem = nth_item(allnum - pagenum); move(2, 0); clrtobot(); prints("[1;44;37m"); printdash("BBS Gopher Îï¼þ»ù±¾×ÊÁÏ"); prints("[m"); prints("ÀàÐÍ£º%c (%s)\n", tmpitem->title[0], (tmpitem->title[0] == '0') ? "Îļþ" : "Ŀ¼"); prints("±êÌ⣺%s\n", tmpitem->title + 1); prints("·¾¶£º%s\n", tmpitem->file); prints("λÖãº%s\n", tmpitem->server); prints("ʹÓãº%d²º\n", tmpitem->port); pressanykey(); g_refresh(); } break; case Ctrl('P'): tmpitem = nth_item(allnum - pagenum); if (!HAS_PERM(PERM_POST)) break; setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { char bname[30]; clear(); if (get_a_boardname(bname, "ÇëÊäÈëҪתÌùµÄÌÖÂÛÇøÃû³Æ: ")) { move(1, 0); sprintf(fpath, "ÄãÈ·¶¨Òª×ªÌùµ½ %s °åÂð", bname); if (askyn(fpath, NA, NA) == 1) { move(2, 0); Postfile(fname, bname, tmpitem->title + 1, 2); sprintf(fpath, "[1mÒѾ°ïÄãתÌùµ½ %s °åÁË...[m", bname); prints(fpath); refresh(); sleep(1); } } } unlink(fname); g_refresh(); return 1; #ifdef INTERNET_EMAIL case 'U': case 'F': case 'u': case 'f': case 'z': case 'Z': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { strncpy(fhdr.title, tmpitem->title + 1, 70); strncpy(fhdr.filename, "gopher.tmp", STRLEN); sethomepath(fpath, currentuser.userid); // if (ch == 'Z' || ch == 'z') // a_download(fname); // else { switch (doforward(fpath, &fhdr, (ch == 'u' || ch == 'U') ? 1 : 0)) { case 0: show_message("ÎÄÕÂת¼ÄÍê³É!"); break; case -1: show_message("system error!!."); break; case -2: show_message("invalid address."); break; default: show_message("È¡Ïûת¼Ä¶¯×÷."); } // } refresh(); pressanykey(); g_refresh(); unlink(fname); return 1; } else return 1; break; #endif default: return 0; } return 1; }
int use_dict() { FILE *fp; char lang[150], word[80] = ""; char j, f, buf[120], sys[] = "|\033[31me\033[m:編籍字典"; int i = 0; setutmpmode(DICT); if(!HAS_PERM(PERM_SYSOP)) sys[0]=0; clear(); sprintf(buf,"\033[45m ●\033[1;44;33m" " %-14s\033[3;45m ● ", dict); strcpy(&buf[100],"\033[m\n"); for(;;) { move(0, 0); sprintf(lang, " 請輸入關鍵字串(%s) 或指令(h,t,a)\n", dict); outs(lang); sprintf(lang, "[\033[32m<關鍵字>\033[m|\033[32mh\033[m:help|\033[32m" "t\033[m:所有資料|\033[32ma\033[m:新增資料%s]\n:", sys); outs(lang); getdata(2, 0, ":", word, 18, DOECHO); outs("資料搜尋中請稍候...."); strcpy(word,lower(word)); if(word[0] == 0) return 0; clear(); move(4, 0); outs(buf); if(strlen(word) == 1) { if(word[0] == 'a') { clear(); move(4,0); outs(buf); addword(word); continue; } else if(word[0] == 't') word[0] = 0; else if(word[0] == 'h') { more("etc/dict.hlp",YEA); clear(); continue; } else if(word[0]=='e') { vedit(database,NA, NULL); clear(); continue; } else { outs("字串太短,請輸入多一點關鍵字"); continue; } } if((fp = fopen(database,"r"))) { i = 0; while(fgets(lang,150,fp) != NULL) { if(lang[65] == '[') { lang[65] = 0; f = 1; } else f = 0; if(strstr(lower(lang),word)) { if(f == 1) lang[65] = '['; outs(lang); i++; if(!((i+1)%17)) { move(23, 0); outs("\033[45m " "任意鍵繼續 Q:離開 " "\033[m "); j = igetch(); if(j == 'q') break; else { clear(); move(4,0); outs(buf); } } } } } fclose(fp); if(i == 0) { getdata(5, 0, "沒這個資料耶,新增嗎?(y/N)", lang, 3, LCECHO); if(lang[0] == 'y') { clear(); move(4,0); outs(buf); addword(word); } } } }
static int tmpl_key(struct _select_def *conf, int key) { int oldmode; switch (key) { case 'a' : tmpl_check_limit(template_num); tmpl_add(); return SHOW_DIRCHANGE; break; case 'd' : { char ans[3]; getdata(t_lines - 1, 0, "确实要删除吗(Y/N)? [N]: ", ans, sizeof(ans), DOECHO, NULL, true); if (ans[0] == 'Y' || ans[0] == 'y') { int i; deepfree(ptemplate + conf->pos - 1, currboard->filename); template_num--; for (i=conf->pos-1; i<template_num; i++) memcpy(ptemplate+i, ptemplate+i+1, sizeof(struct a_template)); ptemplate[template_num].tmpl = NULL; ptemplate[template_num].cont = NULL; tmpl_save(); } if (template_num > 0) return SHOW_DIRCHANGE; else return SHOW_QUIT; } break; case 'c': do { extern bool in_do_sendmsg; extern int super_select_board(char *bname); int ret; char bname[STRLEN] = ""; move(0,0); clrtoeol(); prints("%s","复制到讨论区 [ \033[1;32mSPACE/TAB\033[m - 自动补全, \033[1;32mESC\033[m - 退出 ]"); move(1,0); clrtoeol(); prints("请输入讨论区名称 [\033[1;32m%s\033[m]: ",currboard->filename); make_blist(0, 3); in_do_sendmsg=1; ret = namecomplete(NULL, bname); in_do_sendmsg=0; CreateNameList(); /* free list memory. */ if (ret == KEY_ESC) { /* noop */ } else if (!*bname || !strcmp(bname, currboard->filename)) { /* copy to current board */ tmpl_check_BM(currboard->filename); /* sanity check, how about stick here when deposing? */ tmpl_check_limit(template_num); if (tmpl_copy(conf->pos)) tmplcp_sorry(); else tmplcp_success(); } else { /* copy to another board */ struct a_template *ptemp; int temp_num = tmpl_init_ex(0, bname, &ptemp); if (temp_num >= 0) { tmpl_check_BM(bname); /* sanity check */ tmpl_check_limit(temp_num); if (tmpl_copy_to_board(bname, &ptemp, &temp_num, conf->pos)) tmplcp_sorry(); else tmplcp_success(); tmpl_free_ex(&ptemp, temp_num); } } } while (0); return SHOW_DIRCHANGE; /* etnlegend, 2006.05.19, move templates... */ case 'm': do { struct a_template temp; char ans[4]; int i,pos; getdata(t_lines-1,0,"请输入希望移动到的位置序号: ",ans,4,DOECHO,NULL,true); trimstr(ans); if (!isdigit(ans[0])) break; pos=atoi(ans); pos=((pos<1)?1:((pos>template_num)?template_num:pos)); if (pos==conf->pos) break; memcpy(&temp,&ptemplate[conf->pos-1],sizeof(struct a_template)); if (pos>conf->pos) { for (i=(conf->pos-1); i<(pos-1); i++) memcpy(&ptemplate[i],&ptemplate[i+1],sizeof(struct a_template)); } else { for (i=(conf->pos-1); i>(pos-1); i--) memcpy(&ptemplate[i],&ptemplate[i-1],sizeof(struct a_template)); } memcpy(&ptemplate[pos-1],&temp,sizeof(struct a_template)); tmpl_save(); } while (0); return SHOW_DIRCHANGE; /* END - etnlegend, 2006.05.19, move templates ... */ case 't' : { char newtitle[60]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title); getdata(t_lines - 1, 0, "新名称: ", newtitle, 50, DOECHO, NULL, false); if (newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title)) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title, newtitle, 50); ptemplate[conf->pos-1].tmpl->title[49]='\0'; tmpl_save(); return SHOW_REFRESH; } break;/* case 'z' : { char newtitle[30]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title_prefix); getdata(t_lines - 1, 0, "请输入此模板的文章标题前缀: ", newtitle, 20, DOECHO, NULL, false); if( newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title_prefix) ) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title_prefix, newtitle, 20); ptemplate[conf->pos-1].tmpl->title_prefix[19]='\0'; tmpl_save(); return SHOW_REFRESH; }*/ case 'f' : { char filepath[STRLEN]; int oldmode; oldmode = uinfo.mode; modify_user_mode(EDITUFILE); if (ptemplate[conf->pos-1].tmpl->filename[0] == '\0') { setbfile(filepath, currboard->filename, ""); if (GET_POSTFILENAME(ptemplate[conf->pos-1].tmpl->filename, filepath) != 0) { clear(); move(3,0); prints("创建模板文件失败!"); pressanykey(); return SHOW_REFRESH; } tmpl_save(); } setbfile(filepath, currboard->filename, ptemplate[conf->pos-1].tmpl->filename); vedit(filepath,0,NULL,NULL,0); modify_user_mode(oldmode); return SHOW_REFRESH; } case 's' : { char filepath[STRLEN]; setbfile(filepath, currboard->filename, ptemplate[conf->pos-1].tmpl->filename); clear(); ansimore(filepath,1); return SHOW_REFRESH; } case 'b' : { if (ptemplate[conf->pos-1].tmpl->flag & TMPL_BM_FLAG) ptemplate[conf->pos-1].tmpl->flag &= ~TMPL_BM_FLAG ; else ptemplate[conf->pos-1].tmpl->flag |= TMPL_BM_FLAG; tmpl_save(); return SHOW_REFRESH; } case 'i' : { char newtitle[STRLEN]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title_tmpl); getdata(t_lines - 1, 0, "新文章标题: ", newtitle, STRLEN, DOECHO, NULL, false); if (newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title_tmpl)) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title_tmpl, newtitle, STRLEN); ptemplate[conf->pos-1].tmpl->title_tmpl[STRLEN-1]='\0'; tmpl_save(); return SHOW_REFRESH; } case 'x' : { clear(); move(2,0); prints("此模版的标题设置为"); move(4,0); prints("%s",ptemplate[conf->pos-1].tmpl->title_tmpl); pressanykey(); return SHOW_REFRESH; } /* case 'h': { clear(); move(1,0); prints(" x : 查看标题格式\n"); prints(" i : 修改标题格式"); pressanykey(); return SHOW_REFRESH; } */ case 'l': /* by pig2532 on 2005.12.01 */ oldmode = uinfo.mode; show_allmsgs(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'w': /* by pig2532 on 2005-12-1 */ oldmode = uinfo.mode; if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) break; s_msg(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'u': /* by pig2532 on 2005-12-1 */ clear(); oldmode = uinfo.mode; modify_user_mode(QUERY); t_query(NULL); modify_user_mode(oldmode); return SHOW_REFRESH; case 'U': /* pig2532 2005.12.10 */ board_query(); return SHOW_REFRESH; default : break; } return SHOW_CONTINUE; }