示例#1
0
DeleteAccount()
{
  NAME namebuf;
  int rc;
  char ans[4];
  move(2,0);
  clrtobot();
  bbs_acctnames(&acctlist, NULL);
  namecomplete(NULL, acctlist, "Userid to delete: ", namebuf, sizeof(NAME));
  if (namebuf[0] == '\0' || !is_in_namelist(acctlist, namebuf)) {
    bbperror(S_NOSUCHUSER, NULL);
    pressreturn();
    return FULLUPDATE;
  }
  prints("Deleting user '%s'.\n", namebuf);
  getdata(5,0,"Are you sure (Y/N)? [N]: ",ans,sizeof(ans),DOECHO,0);    
  if (ans[0] != 'Y' && ans[0] != 'y') {
    prints("Account not deleted.\n");
    pressreturn();
    return FULLUPDATE;
  }
  rc = bbs_delete_account(namebuf);
  if (rc == S_OK)
    prints("Account deleted.\n");
  else
    bbperror(rc, "Account deletion failed");

  pressreturn();
  return FULLUPDATE;
}
示例#2
0
文件: board.c 项目: foxfair/formosa
int namecomplete_board(BOARDHEADER *bhp, char *data, BOOL simple)
{
	struct word *bwtop = NULL;
	int i;


	if (!num_brds)
	{
		CreateBoardList(&curuser);
		if (num_brds <= 0)
			return -1;
	}
	if (!simple)
	{
		move(1, 0);
		clrtobot();
		move(2, 0);
		outs(_msg_board_5);
		move(1, 0);
		outs(_msg_board_6);
	}
	for (i = 0; i < num_brds; i++)
		add_wlist(&bwtop, (all_brds[i].bhr)->filename, NULL);
	namecomplete(bwtop, data, simple);
	free_wlist(&bwtop, NULL);
	if (data[0] == '\0')
		return -1;
	if (bhp)
		return get_board(bhp, data);
	return 0;
}
示例#3
0
SetUserData()
{
  NAME userid;
  ACCOUNT acct, nr;
  int rc;
  SHORT flags = 0;
  PASSWD passcfm;
  int x, y, grok;
  char genbuf[256], ans[4];
  move(2,0);
  memset(&nr, 0, sizeof nr);
  bbs_acctnames(&acctlist, NULL);
  namecomplete(NULL, acctlist, "Userid to set: ", userid, sizeof(NAME)); 
  if (userid[0] == '\0' || !is_in_namelist(acctlist, userid)) {
    bbperror(S_NOSUCHUSER, NULL);
    pressreturn();
    return FULLUPDATE;
  }
  if ((rc = bbs_get_userinfo(userid, &acct)) != S_OK) {
    bbperror(rc, NULL);
    pressreturn();
    return FULLUPDATE;
  }
  move(3,0);
  UserDisplay(&acct);
  getyx(&y, &x);
  getdata(++y,0,"Change any user information (Y/N)? [N]: ",ans,sizeof(ans),
	  DOECHO, 0);
  if (ans[0] != 'Y' && ans[0] != 'y') {
    prints("Record not changed.\n");
    pressreturn();
    return FULLUPDATE;
  }
  
  sprintf(genbuf, "New userid [%s]: ", acct.userid);
  do {
    getdata(y+1, 0, genbuf, nr.userid, sizeof(nr.userid), DOECHO, 0);
    if (!nr.userid[0])
      break;
    if (grok = CheckUserid(nr.userid)) {
      move(y+2, 0);
      prints("Invalid or taken userid. Try again.\n");
    }
    else BITSET(flags, MOD_USERID);
  } while (grok);
  y++;
  
  do {
    getdata(y+1,0,"New Password: "******"Confirm Pass: "******"Passwords don't match. Try again.\n");
    }
    else BITSET(flags, MOD_PASSWD);
  } while (grok);
  move(y+2, 0);    
  clrtobot();
  y+=2;
  
  sprintf(genbuf, "New username [%s]: ", acct.username);
  getdata(y++, 0, genbuf, nr.username, sizeof(nr.username), DOECHO, 0);
  if (nr.username[0]) BITSET(flags, MOD_USERNAME);
  
  sprintf(genbuf, "New terminal type [%s]: ", acct.terminal);
  getdata(y++, 0, genbuf, nr.terminal, sizeof(nr.terminal), DOECHO, 0);
  if (nr.terminal[0]) BITSET(flags, MOD_TERMINAL);
  
  sprintf(genbuf, "New charset [%s]: ", acct.charset);
  getdata(y++, 0, genbuf, nr.charset, sizeof(nr.charset), DOECHO, 0);
  if (nr.charset[0]) BITSET(flags, MOD_CHARSET);
 
  sprintf(genbuf, "New real name [%s]: ", acct.realname);
  getdata(y++, 0, genbuf, nr.realname, sizeof(nr.realname), DOECHO, 0);
  if (nr.realname[0]) BITSET(flags, MOD_REALNAME);
  
  sprintf(genbuf, "New address: ");
  getdata(y++, 0, genbuf, nr.address, sizeof(nr.address), DOECHO, 0);
  if (nr.address[0]) BITSET(flags, MOD_ADDRESS);
  
  sprintf(genbuf, "New mail address: ");
  getdata(y++, 0, genbuf, nr.email, sizeof(nr.email), DOECHO, 0);
  if (nr.email[0]) BITSET(flags, MOD_EMAIL);
  
  getdata(y, 0, "Are you sure (Y/N)? [N]: ", ans, sizeof(ans), DOECHO, 0);
  if (ans[0] == 'Y' || ans[0] == 'y') {    
    rc = bbs_modify_account(acct.userid, &nr, flags);
    if (rc == S_OK)
      prints("User data was changed.\n");
    else
      bbperror(rc, "User modify failed");
  }
  else prints("User data not changed.\n");
  
  pressreturn();
  return FULLUPDATE;
}
示例#4
0
文件: wind.c 项目: dancrossnyc/harvey
void
wkeyctl(Window *w, Rune r)
{

	uint q0;

	if(r == 0)
		return;
	if(w->deleted)
		return;
	fprint(2, "wkyctl: skipping all ctl chars\n");
#if 0
	uint q0 ,q1;
	int n, nb, nr;

	Rune *rp;
	int *notefd;
	/* navigation keys work only when mouse is not open */
	if(!w->mouseopen)
		switch(r){
		case Kdown:
			n = w->maxlines/3;
			goto case_Down;
		case Kscrollonedown:
			n = mousescrollsize(w->maxlines);
			if(n <= 0)
				n = 1;
			goto case_Down;
		case Kpgdown:
			n = 2*w->maxlines/3;
		case_Down:
			q0 = w->org+frcharofpt(w, Pt(w->Frame.r.min.x, w->Frame.r.min.y+n*w->font->height));
			wsetorigin(w, q0, TRUE);
			return;
		case Kup:
			n = w->maxlines/3;
			goto case_Up;
		case Kscrolloneup:
			n = mousescrollsize(w->maxlines);
			if(n <= 0)
				n = 1;
			goto case_Up;
		case Kpgup:
			n = 2*w->maxlines/3;
		case_Up:
			q0 = wbacknl(w, w->org, n);
			wsetorigin(w, q0, TRUE);
			return;
		case Kleft:
			if(w->q0 > 0){
				q0 = w->q0-1;
				wsetselect(w, q0, q0);
				wshow(w, q0);
			}
			return;
		case Kright:
			if(w->q1 < w->nr){
				q1 = w->q1+1;
				wsetselect(w, q1, q1);
				wshow(w, q1);
			}
			return;
		case Khome:
			wshow(w, 0);
			return;
		case Kend:
			wshow(w, w->nr);
			return;
		case 0x01:	/* ^A: beginning of line */
			if(w->q0==0 || w->q0==w->qh || w->run[w->q0-1]=='\n')
				return;
			nb = wbswidth(w, 0x15 /* ^U */);
			wsetselect(w, w->q0-nb, w->q0-nb);
			wshow(w, w->q0);
			return;
		case 0x05:	/* ^E: end of line */
			q0 = w->q0;
			while(q0 < w->nr && w->run[q0]!='\n')
				q0++;
			wsetselect(w, q0, q0);
			wshow(w, w->q0);
			return;
		}
	if(w->rawing && (w->q0==w->nr || w->mouseopen)){
		waddraw(w, &r, 1);
		return;
	}
	if(r==0x1B || (w->holding && r==0x7F)){	/* toggle hold */
		if(w->holding)
			--w->holding;
		else
			w->holding++;
		wrepaint(w);
		if(r == 0x1B)
			return;
	}
	if(r != 0x7F){
		wsnarf(w);
		wcut(w);
	}
	switch(r){
	case 0x7F:		/* send interrupt */
		w->qh = w->nr;
		wshow(w, w->qh);
		notefd = emalloc(sizeof(int));
		*notefd = w->notefd;
		proccreate(interruptproc, notefd, 4096);
		return;
	case 0x06:	/* ^F: file name completion */
	case Kins:		/* Insert: file name completion */
		rp = namecomplete(w);
		if(rp == nil)
			return;
		nr = runestrlen(rp);
		q0 = w->q0;
		q0 = winsert(w, rp, nr, q0);
		wshow(w, q0+nr);
		free(rp);
		return;
	case 0x08:	/* ^H: erase character */
	case 0x15:	/* ^U: erase line */
	case 0x17:	/* ^W: erase word */
		if(w->q0==0 || w->q0==w->qh)
			return;
		nb = wbswidth(w, r);
		q1 = w->q0;
		q0 = q1-nb;
		if(q0 < w->org){
			q0 = w->org;
			nb = q1-q0;
		}
		if(nb > 0){
			wdelete(w, q0, q0+nb);
			wsetselect(w, q0, q0);
		}
		return;
	}

	wshow(w, q0+1);
#endif
	/* otherwise ordinary character; just insert */
	q0 = w->q0;
	q0 = winsert(w, &r, 1, q0);
}
示例#5
0
文件: tmpl.c 项目: zhouqt/kbs
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;
}