示例#1
0
int usercomplete(char *prompt, char *data) {
	char *cwbuf, *cwlist, *temp;
	int cwnum, x, y, origx, origy;
	int clearbot = NA, count = 0, morenum = 0;
	char ch;

	cwbuf = malloc(MAXUSERS * (IDLEN + 1));
	if (prompt != NULL) {
		prints("%s", prompt);
		clrtoeol();
	}
	temp = data;
	cwlist = u_namearray((void *)cwbuf, &cwnum, "");
	screen_coordinates(&y, &x);
	screen_coordinates(&origy, &origx);
	while ((ch = terminal_getchar()) != EOF) {
		if (ch == '\n' || ch == '\r') {
			int i;
			char *ptr;

			*temp = '\0';
			prints("\n");
			ptr = cwlist;
			for (i = 0; i < cwnum; i++) {
				if (strncasecmp(data, ptr, IDLEN + 1) == 0)
					strcpy(data, ptr);
				ptr += IDLEN + 1;
			}
			/* if( cwnum == 1 ) strcpy( data, cwlist ); */
			break;
		} // if
		if (ch == ' ' || ch == KEY_TAB) {
			int col, len, i, j;
			int n;

			if (cwnum == 1) {
				strcpy(data, cwlist);
				screen_move(y, x);
				prints("%s", data + count);
				count = strlen(data);
				temp = data + count;
				screen_coordinates(&y, &x);
				continue;
			}
			for (i = strlen(data); i && i < IDLEN; i++) {
				ch = cwlist[i];
				if (ch == '\0')
					break;
				for (j = 0; j < cwnum; j++) {
					if (toupper((cwlist + (IDLEN + 1) * j)[i]) != toupper(ch))
						break;
				}
				if (j != cwnum)
					break;
				*temp++ = ch;
				*temp = '\0';
				n = UserSubArray((void *)cwbuf, (void *)cwlist, cwnum, ch,
						count);
				if (n == 0) {
					temp--;
					*temp = '\0';
					break;
				}
				cwlist = cwbuf;
				count++;
				cwnum = n;
				morenum = 0;
				screen_move(y, x);
				outc(ch);
				x++;
			}
			clearbot = YEA;
			col = 0;
			len = UserMaxLen((void *)cwlist, cwnum, morenum, NUMLINES);
			screen_move(origy + 1, 0);
			screen_clrtobot();
			//% printdash(" 所有使用者列表 ");
			printdash(" \xcb\xf9\xd3\xd0\xca\xb9\xd3\xc3\xd5\xdf\xc1\xd0\xb1\xed ");
			while (len + col < 79) {
				int i;
				for (i = 0; morenum < cwnum && i < NUMLINES - origy + 1; i++) {
					char *tmpptr = cwlist + (IDLEN + 1) * morenum++;
					if (*tmpptr != '\0') { //by Eric
						screen_move(origy + 2 + i, col);
						prints("%s ", tmpptr);
					} else
						i--;
				}
				col += len + 2;
				if (morenum >= cwnum)
					break;
				len = UserMaxLen((void *)cwlist, cwnum, morenum, NUMLINES);
			}
			if (morenum < cwnum) {
				screen_move(-1, 0);
				//% prints("-- 还有使用者 --                                                               ");
				prints("-- \xbb\xb9\xd3\xd0\xca\xb9\xd3\xc3\xd5\xdf --                                                               ");
			} else {
				morenum = 0;
			}
			screen_move(y, x);
			continue;
		}
		if (ch == '\177' || ch == '\010') {
			if (temp == data)
				continue;
			temp--;
			count--;
			*temp = '\0';
			cwlist = u_namearray((void *)cwbuf, &cwnum, data);
			morenum = 0;
			x--;
			screen_move(y, x);
			outc(' ');
			screen_move(y, x);
			continue;
		}
		if (count < STRLEN) {
			int n;
			*temp++ = ch;
			*temp = '\0';
			n = UserSubArray((void *)cwbuf, (void *)cwlist, cwnum, ch,
					count);
			if (n == 0) {
				temp--;
				*temp = '\0';
				continue;
			}
			cwlist = cwbuf;
			count++;
			cwnum = n;
			morenum = 0;
			screen_move(y, x);
			outc(ch);
			x++;
		}
	}
	free(cwbuf);
	if (ch == EOF)
		longjmp(byebye, -1);
	prints("\n");
	screen_flush();
	if (clearbot) {
		screen_move(origy, 0);
		screen_clrtobot();
	}
	if (*data) {
		screen_move(origy, origx);
		prints("%s\n", data);
	}
	return 0;
}
示例#2
0
int namecomplete(char *prompt, char *data) {
	char *temp;
	int ch;
	int count = 0;
	int clearbot = NA;
	struct word *cwlist, *morelist;
	int x, y;
	int origx, origy;

	if (prompt != NULL) {
		prints("%s", prompt);
		clrtoeol();
	}
	temp = data;

	if (toplev == NULL)
		AddNameList("");
	cwlist = GetSubList("", toplev);
	morelist = NULL;
	screen_coordinates(&y, &x);
	screen_coordinates(&origy, &origx);
	while ((ch = terminal_getchar()) != EOF) {
		if (ch == '\n' || ch == '\r') {
			*temp = '\0';
			prints("\n");
			if (NumInList(cwlist) == 1)
				strcpy(data, cwlist->name);
			else { /*  版面 ID 选择的一个精确匹配问题  period */
				struct word *list;
				for (list = cwlist; list != NULL; list = list->next) {
					if (!strcasecmp(data, list->name)) {
						strcpy(data, list->name);
						break;
					} //if
				} //for
			} //else
			ClearSubList(cwlist);
			break;
		}
		if (ch == ' ' || ch == KEY_TAB) {
			int col, len, i;
			if (NumInList(cwlist) == 1) {
				strcpy(data, cwlist->name);
				screen_move(y, x);
				prints("%s", data + count);
				count = strlen(data);
				temp = data + count;
				screen_coordinates(&y, &x);
				continue;
			}
			for (i = strlen(data); i && i < STRLEN; i++) {
				struct word *node;

				ch = cwlist->name[i];
				if (ch == '\0')
					break;
				for (node = cwlist; node; node = node->next) {
					if (toupper(ch) != toupper(node->name[i]))
						break;
				}
				if (node != NULL)
					break;
				*temp++ = ch;
				count++;
				*temp = '\0';
				node = GetSubList(data, cwlist);
				if (node == NULL) {
					temp--;
					*temp = '\0';
					count--;
					break;
				}
				ClearSubList(cwlist);
				cwlist = node;
				morelist = NULL;
				screen_move(y, x);
				outc(ch);
				x++;
			} //for
			clearbot = YEA;
			col = 0;
			if (!morelist)
				morelist = cwlist;
			len = MaxLen(morelist, NUMLINES);
			screen_move(origy + 1, 0);
			screen_clrtobot();
			prints(ANSI_CMD_SO);
			//% printdash(" 列表 ");
			printdash(" \xc1\xd0\xb1\xed ");
			prints(ANSI_CMD_SE);
			while (len + col < 80) {
				int i;
				for (i = NUMLINES; (morelist) && (i > origy - 1); i--) {
					if (morelist->name[0] != '\0') {
						screen_move(origy + 2 + (NUMLINES - i), col);
						prints("%s", morelist->name);
					} else {
						i++;
					}
					morelist = morelist->next;
				}
				col += len + 2;
				if (!morelist)
					break;
				len = MaxLen(morelist, NUMLINES);
			} //while
			if (morelist) {
				screen_move(-1, 0);
				//% prints("-- 还有 --                                                                     ");
				prints("-- \xbb\xb9\xd3\xd0 --                                                                     ");
			}
			screen_move(y, x);
			continue;
		}
		if (ch == '\177' || ch == '\010') {
			if (temp == data)
				continue;
			temp--;
			count--;
			*temp = '\0';
			ClearSubList(cwlist);
			cwlist = GetSubList(data, toplev);
			morelist = NULL;
			x--;
			screen_move(y, x);
			outc(' ');
			screen_move(y, x);
			continue;
		} //if
		if (count < STRLEN) {
			struct word *node;
			*temp++ = ch;
			count++;
			*temp = '\0';
			node = GetSubList(data, cwlist);
			if (node == NULL) {
				temp--;
				*temp = '\0';
				count--;
				continue;
			}
			ClearSubList(cwlist);
			cwlist = node;
			morelist = NULL;
			screen_move(y, x);
			outc(ch);
			x++;
		}
	} // while
	if (ch == EOF)
		longjmp(byebye, -1);
	prints("\n");
	screen_flush();
	if (clearbot) {
		screen_move(origy, 0);
		screen_clrtobot();
	}
	if (*data) {
		screen_move(origy, origx);
		prints("%s\n", data);
		/* for (x=1; x<500; x++);  delay */
	}
	return 0;
}
示例#3
0
文件: name.c 项目: YanlongLai/Program
void usercomplete(char *prompt, char *data) {
    char *temp;
    char *cwbuf, *cwlist;
    int cwnum, x, y, origx, origy;
    int clearbot = NA, count = 0, morenum = 0;
    char ch;

    cwbuf = malloc(MAX_USERS * (IDLEN + 1));
    cwlist = u_namearray((arrptr)cwbuf, &cwnum, "");
    temp = data;
    
    outs(prompt);
    clrtoeol();
    getyx(&y, &x);
    getyx(&origy, &origx);
    standout();
    prints("%*s", IDLEN + 1, "");
    standend();
    move(y, x);
    while((ch = igetch()) != EOF) {
	if(ch == '\n' || ch == '\r') {
	    int i;
	    char *ptr;
	    
	    *temp = '\0';
	    outc('\n');
	    ptr = (char *)cwlist;
	    for(i = 0; i < cwnum; i++) {
		if(strncasecmp(data, ptr, IDLEN + 1) == 0)
		    strcpy(data, ptr);
		ptr += IDLEN + 1;
	    }
	    break;
	} else if(ch == ' ') {
	    int col, len;
	    
	    if(cwnum == 1) {
		strcpy(data, (char *)cwlist);
		move(y, x);
		outs(data + count);
		count = strlen(data);
		temp = data + count;
		getyx(&y, &x);
		continue;
	    }
	    clearbot = YEA;
	    col = 0;
	    len = UserMaxLen((arrptr)cwlist, cwnum, morenum, p_lines);
	    move(2, 0);
	    clrtobot();
	    printdash("使用者代號一覽表");
	    while(len + col < 79) {
		int i;
		
		for(i = 0; morenum < cwnum && i < p_lines; i++)	{
		    move(3 + i, col);
		    prints("%s ", cwlist + (IDLEN + 1) * morenum++);
		}
		col += len + 2;
		if(morenum >= cwnum)
		    break;
		len = UserMaxLen((arrptr)cwlist, cwnum, morenum, p_lines);
	    }
	    if(morenum < cwnum) {
		move(b_lines, 0);
		outs(msg_more);
	    } else
		morenum = 0;
	    move(y, x);
	    continue;
	} else if(ch == '\177' || ch == '\010') {
	    if(temp == data)
		continue;
	    temp--;
	    count--;
	    *temp = '\0';
	    cwlist = u_namearray((arrptr)cwbuf, &cwnum, data);
	    morenum = 0;
	    x--;
	    move(y, x);
	    outc(' ');
	    move(y, x);
	    continue;
	} else if(count < STRLEN && isprint(ch)) {
	    int n;
	    
	    *temp++ = ch;
	    *temp = '\0';
	    n = UserSubArray((arrptr)cwbuf, (arrptr)cwlist, cwnum, ch, count);
	    if(n == 0) {
		temp--;
		*temp = '\0';
		continue;
	    }
	    cwlist = cwbuf;
	    count++;
	    cwnum = n;
	    morenum = 0;
	    move(y, x);
	    outc(ch);
	    x++;
	}
    }
    free(cwbuf);
    if(ch == EOF)
	/* longjmp(byebye, -1); */
	raise(SIGHUP);	/* jochang: don't know if this is necessary */
    outc('\n');
    refresh();
    if(clearbot) {
	move(2, 0);
	clrtobot();
    }
    if(*data) {
	move(origy, origx);
	outs(data);
	outc('\n');
    }
}
示例#4
0
文件: name.c 项目: YanlongLai/Program
void namecomplete(char *prompt, char *data) {
    char *temp;
    word_t *cwlist, *morelist;
    int x, y, origx, origy;
    int ch;
    int count = 0;
    int clearbot = NA;
    
    if(toplev == NULL)
	AddNameList("");
    cwlist = GetSubList("", toplev);
    morelist = NULL;
    temp = data;
    
    outs(prompt);
    clrtoeol();
    getyx(&y, &x);
    getyx(&origy, &origx);
    standout();
    prints("%*s", IDLEN + 1, "");
    standend();
    move(y, x);
    refresh();
    
    while((ch = igetch()) != EOF) {
	if(ch == '\n' || ch == '\r') {
	    *temp = '\0';
	    outc('\n');
	    if(NumInList(cwlist) == 1)
		strcpy(data, cwlist->word);
	    ClearSubList(cwlist);
	    break;
	}
	if(ch == ' ') {
	    int col, len;
	    
	    if(NumInList(cwlist) == 1) {
		strcpy(data, cwlist->word);
		move(y, x);
		outs(data + count);
		count = strlen(data);
		temp = data + count;
		getyx(&y, &x);
		continue;
	    }
	    clearbot = YEA;
	    col = 0;
	    if(!morelist)
		morelist = cwlist;
	    len = MaxLen(morelist, p_lines);
	    move(2, 0);
	    clrtobot();
	    printdash("相關資訊一覽表");
	    while(len + col < 80) {
		int i;
		
		for(i = p_lines; (morelist) && (i > 0); i--) {
		    move(3 + (p_lines - i), col);
		    outs(morelist->word);
		    morelist = morelist->next;
		}
		col += len + 2;
		if(!morelist)
		    break;
		len = MaxLen(morelist, p_lines);
	    }
	    if(morelist) {
		move(b_lines, 0);
		outs(msg_more);
	    }
	    move(y, x);
	    continue;
	}
	if(ch == '\177' || ch == '\010') {
	    if(temp == data)
		continue;
	    temp--;
	    count--;
	    *temp = '\0';
	    ClearSubList(cwlist);
	    cwlist = GetSubList(data, toplev);
	    morelist = NULL;
	    x--;
	    move(y, x);
	    outc(' ');
	    move(y, x);
	    continue;
	}
	
	if(count < STRLEN && isprint(ch)) {
	    word_t *node;

	    *temp++ = ch;
	    count++;
	    *temp = '\0';
	    node = GetSubList(data, cwlist);
	    if(node == NULL) {
		temp--;
		*temp = '\0';
		count--;
		continue;
	    }
	    ClearSubList(cwlist);
	    cwlist = node;
	    morelist = NULL;
	    move(y, x);
	    outc(ch);
	    x++;
	}
    }
    if(ch == EOF)
	/* longjmp(byebye, -1); */
	raise(SIGHUP);	/* jochang: don't know if this is necessary... */
    outc('\n');
    refresh();
    if(clearbot) {
	move(2, 0);
	clrtobot();
    }
    if(*data) {
	move(origy, origx);
	outs(data);
	outc('\n');
    }
}
示例#5
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("");
			printdash("BBS Gopher Îï¼þ»ù±¾×ÊÁÏ");
			prints("");
			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, "ÒѾ­°ïÄãתÌùµ½ %s °åÁË...", 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;
}
示例#6
0
int scan_register_form(char* regfile)
{
    static char *field[] = {"usernum", "userid", "realname", "dept",
                            "addr", "phone", "regip", NULL
                           };
    static char *finfo[] = {"帐号位置", "申请帐号", "真实姓名", "学校系级",
                            "目前住址", "连络电话", "注册ip  ", NULL
                           };
    static char *reason[] = {"请确实填写真实姓名(不可使用拼音).",
                             "请详填学校院系与年级 (注明系和年级或者工作单位和工作部门).",
                             "请填写完整的住址资料 (完整详细,能够通信).",
                             "请详填连络电话 (固定电话需填写区号).",
                             "请勿穿梭注册.",
                             "请如实详细填写注册申请表.",
                             "请用中文填写申请表.",
                             "同一个用户注册了过多ID.", NULL
                            };
    struct userec uinfo;
    FILE   *fn, *fout, *freg;
    char    fdata[7][STRLEN];
    char    fname[STRLEN], buf[STRLEN];
    char    ans[5], *ptr, *uid;
    int     n, unum;
    uid = currentuser.userid;
    char numofreason[2];//tdhlshx for refuse.
    int total;
    int iis;
    int realnumofrea[8];//add end

    stand_title("依序设定所有新注册资料");
    sprintf(fname, "%s.tmp", regfile);
    move(2, 0);
    if (dashf(fname))
    {
        move(1, 0);
        prints("其他 SYSOP 正在查看注册申请单, 请检查使用者状态.\n");
        getdata(2, 0, "你确定没有其他 SYSOP 在审核注册单吗 ? [y/N]: ", ans, 2, DOECHO, YEA);
        if (ans[0] == 'Y' || ans[0] == 'y')
            f_cp(fname, regfile, O_APPEND);
        else
        {
            pressreturn();
            return -1;
        }
    }
    rename(regfile, fname);
    if ((fn = fopen(fname, "r")) == NULL)
    {
        move(2, 0);//请管理员输入未通过原因:
        prints("系统错误, 无法读取注册资料档: %s\n", fname);
        pressreturn();
        return -1;
    }
    memset(fdata, 0, sizeof(fdata));
    while (fgets(genbuf, STRLEN, fn) != NULL)
    {
        if ((ptr = (char *) strstr(genbuf, ": ")) != NULL)
        {
            *ptr = '\0';
            for (n = 0; field[n] != NULL; n++)
            {
                if (strcmp(genbuf, field[n]) == 0)
                {
                    strcpy(fdata[n], ptr + 2);
                    if ((ptr = (char *) strchr(fdata[n], '\n')) != NULL)
                        *ptr = '\0';
                }
            }
        }
        else if ((unum = getuser(fdata[1])) == 0)
        {
            move(2, 0);
            clrtobot();
            prints("系统错误, 查无此帐号.\n\n");
            for (n = 0; field[n] != NULL; n++)
                prints("%s     : %s\n", finfo[n], fdata[n]);
            pressreturn();
            memset(fdata, 0, sizeof(fdata));
        }
        else
        {
            memcpy(&uinfo, &lookupuser, sizeof(uinfo));
            move(1, 0);
            prints("帐号位置     : %d\n", unum);
            disply_userinfo(&uinfo);
            move(15, 0);
            printdash(NULL);
            for (n = 0; field[n] != NULL; n++)
                prints("%s     : %s\n", finfo[n], fdata[n]);
            if (uinfo.userlevel & PERM_LOGINOK)
            {
                move(t_lines - 1, 0);
                prints("此帐号不需再填写注册单.\n");
                igetkey();
                ans[0] = 'D';
            }
            else
            {
                getdata(t_lines - 1, 0, "是否接受此资料 (Y/N/Q/Del/Skip)? [S]: ",
                        ans, 3, DOECHO, YEA);
            }
            move(1, 0);
            clrtobot();
            switch (ans[0])
            {
            case 'D':
            case 'd':
                break;
            case 'Y':
            case 'y':
                prints("以下使用者资料已经更新:\n");
                n = strlen(fdata[5]);
                if (n + strlen(fdata[3]) > 60)
                {
                    if (n > 40)
                        fdata[5][n = 40] = '\0';
                    fdata[3][60 - n] = '\0';
                }
                strncpy(uinfo.realname, fdata[2], NAMELEN);
                strncpy(uinfo.address, fdata[4], NAMELEN);
                sprintf(genbuf, "%s$%s@%s", fdata[3], fdata[5], uid);
                genbuf[STRLEN - 16] = '\0';
                strncpy(uinfo.reginfo, genbuf, STRLEN - 17);
#ifdef ALLOWGAME

                uinfo.money = 1000;
#endif

                uinfo.lastjustify = time(0);
                substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum);
                sethomefile(buf, uinfo.userid, "register");
                if (dashf(buf))
                {
                    sethomefile(genbuf, uinfo.userid, "register.old");
                    rename(buf, genbuf);
                }
                if ((fout = fopen(buf, "w")) != NULL)
                {
                    for (n = 0; field[n] != NULL; n++)
                        fprintf(fout, "%s: %s\n", field[n], fdata[n]);
                    n = time(NULL);
                    getdatestring(n,NA);
                    fprintf(fout, "Date: %s\n", datestring);
                    fprintf(fout, "Approved: %s\n", uid);
                    fclose(fout);
                }
                mail_file("etc/s_fill", uinfo.userid, "恭禧你,你已经完成注册。");
                mail_file("etc/fornewcomers",uinfo.userid,"欢迎加入 "BBSNAME" 大家庭");//tdhlshx 新手FAQ信件
                sethomefile(buf, uinfo.userid, "mailcheck");
                unlink(buf);
                sprintf(genbuf, "让 %s 通过身份确认.", uinfo.userid);
                securityreport4(genbuf);
                break;
            case 'Q':
            case 'q':
                if ((freg = fopen(regfile, "a")) != NULL)
                {
                    for (n = 0; field[n] != NULL; n++)
                        fprintf(freg, "%s: %s\n", field[n], fdata[n]);
                    fprintf(freg, "----\n");
                    while (fgets(genbuf, STRLEN, fn) != NULL)
                        fputs(genbuf, freg);
                    fclose(freg);
                }
                break;
            case 'N':
            case 'n':
                for(total=0; total<8; total++)
                    realnumofrea[total]=0;
                for (n = 0; field[n] != NULL; n++)
                    prints("%s: %s\n", finfo[n], fdata[n]);
                printdash(NULL);
                move(9, 0);
                prints("请依次输入退回申请表原因的序号并回车确认,直接回车结束.\n\n");
                //	prints("请选择/输入退回申请表原因, 按 <enter> 取消.\n\n");
                for (n = 0; reason[n] != NULL; n++)
                    prints("%d) %s\n", n, reason[n]);
                getdata(12+n,0,"退回原因:",numofreason,2,DOECHO,YEA);
                //	getdata(12 + n, 0, "退回原因: ", buf, 60, DOECHO, YEA);
                if(numofreason[0]!='\0'&&numofreason[0]>='0'&&numofreason[0]<='7')
                {
                    total=atoi(numofreason);
                    realnumofrea[total]=1;
                    move(14+n,0);
                    prints("您已经选择的理由有:\n%d  ",total);
                }
                while(numofreason[0]!='\0')
                {
                    getdata(12+n,0,"退回原因:",numofreason,2,DOECHO,YEA);
                    if(numofreason[0]>='0'&&numofreason[0]<='7')
                    {
                        total=atoi(numofreason);
                        if(realnumofrea[total]==0)
                            realnumofrea[total]=1;
                        else
                            realnumofrea[total]=0;
                        move(14+n,0);
                        clrtobot();
                        prints("您已经选择的理由有:\n");
                        for(iis=0; iis<8; iis++)
                        {
                            if(realnumofrea[iis]==1)
                                prints("%d  ",iis);
                        }
                    }
                }
                system("cp /home/bbs/etc/f_fill  /home/bbs/tmp/fletter");
                char FL[STRLEN];
                sprintf(FL,"/home/bbs/tmp/fletter");
                FILE * fail=fopen(FL,"a");
                if(fail==NULL)
                {
                    prints("Error,创建临时文件错误.请与系统维护联系或再次尝试!");
                    pressanykey();
                    return -1;
                }

                {
                    fprintf(fail,"\n\n您被拒绝注册的原因大概如下:\n");
                    for(total=0; total<8; total++)
                    {
                        if(realnumofrea[total]==1)
                        {
                            strcpy(buf,reason[total]);
                            fprintf(fail,"\n%s",buf);
                        }
                    }
                    sprintf(genbuf,"很抱歉的告诉您,您这次注册失败.:(");
                    strncpy(uinfo.address, genbuf, NAMELEN);
                    substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum);
                    fclose(fail);
                    mail_file(FL,uinfo.userid, uinfo.address);
                    system("rm -f /home/bbs/tmp/fletter");

                }
                break;
            /*if (buf[0] != '\0') {
            if (buf[0] >= '0' && buf[0] < '0' + n) {
            	strcpy(buf, reason[buf[0] - '0']);
            }
            sprintf(genbuf, "<注册失败> - %s", buf);
            strncpy(uinfo.address, genbuf, NAMELEN);
            substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum);
            mail_file("etc/f_fill", uinfo.userid, uinfo.address);*/
            /* user_display( &uinfo, 1 ); */
            /* pressreturn(); */
            /*	break;
            }
            move(10, 0);
            clrtobot();
            prints("取消退回此注册申请表.\n");*/
            /* run default -- put back to regfile */
            default:
                if ((freg = fopen(regfile, "a")) != NULL)
                {
                    for (n = 0; field[n] != NULL; n++)
                        fprintf(freg, "%s: %s\n", field[n], fdata[n]);
                    fprintf(freg, "----\n");
                    fclose(freg);
                }
            }
            memset(fdata, 0, sizeof(fdata));
        }
    }
    fclose(fn);
    unlink(fname);
    return (0);
}