Ejemplo n.º 1
0
void main_loop()
{
    int i;
    POINT pts[MAXSTATION];

    for (i = 0; i < MAXSTATION; i++) {
        pts[i].x = i / 19 * 24 + 2;
        pts[i].y = i % 19+1;
    };
    bzero(&bbsnet_conf,sizeof(bbsnet_conf));
    load_data(&bbsnet_conf,0,MAXSTATION);
    bbsnet_conf.flag = LF_FORCEREFRESHSEL | LF_BELL | LF_LOOP;     //|LF_HILIGHTSEL;
    bbsnet_conf.prompt = NULL;
    bbsnet_conf.item_pos = pts;
    bbsnet_conf.arg = NULL;
    bbsnet_conf.title_pos.x = 0;
    bbsnet_conf.title_pos.y = 0;
    bbsnet_conf.pos = 1;
    bbsnet_conf.page_pos = 1;

    bbsnet_conf.on_select = bbsnet_onselect;
    bbsnet_conf.show_data = bbsnet_show;
    bbsnet_conf.key_command = bbsnet_key;
    bbsnet_conf.show_title = bbsnet_refresh;
    bbsnet_conf.get_data = load_data;
    bbsnet_conf.on_selchange = bbsnet_selchange;
    bbsnet_conf.item_per_page = bbsnet_conf.item_count;

    list_select_loop(&bbsnet_conf);
}
Ejemplo n.º 2
0
Archivo: bbsnet.c Proyecto: wyat/kbs
void main_loop()
{
    int i;
    POINT pts[MAXSTATION];
    struct _select_def bbsnet_conf;

    for (i = 0; i < MAXSTATION; i++) {
        pts[i].x = 2 + ((i>=17)?20:0) + ((i>=34)?20:0) + ((i>=51)?20:0);
        pts[i].y = i + 2 -((i>=17)?17:0) - ((i>=34)?17:0) - ((i>=51)?17:0);
    };

    sectionindex=1;
    bzero(&bbsnet_conf,sizeof(bbsnet_conf));
    load_section(&bbsnet_conf,1,MAXSTATION);
    bbsnet_conf.item_per_page = bbsnet_conf.item_count;
    bbsnet_conf.flag = LF_FORCEREFRESHSEL | LF_BELL | LF_LOOP;     //|LF_HILIGHTSEL;
    bbsnet_conf.prompt = NULL;
    bbsnet_conf.item_pos = pts;
    bbsnet_conf.arg = NULL;
    bbsnet_conf.title_pos.x = 0;
    bbsnet_conf.title_pos.y = 0;
    bbsnet_conf.pos = 1;
    bbsnet_conf.page_pos = 1;

    bbsnet_conf.on_select = bbsnet_onselect;
    bbsnet_conf.show_data = bbsnet_show;
    bbsnet_conf.key_command = bbsnet_key;
    bbsnet_conf.show_title = bbsnet_refresh;
    bbsnet_conf.get_data = load_section;
    bbsnet_conf.on_selchange = bbsnet_selchange;
    list_select_loop(&bbsnet_conf);
}
Ejemplo n.º 3
0
int smsmsg_read(void)
{
    struct _select_def group_conf;
    int i;
    POINT *pts;

    sm_dest[0]=0;

    s_m = (struct smsmsg *) malloc(sizeof(struct smsmsg) * BBS_PAGESIZE);
    if (s_m == NULL)
        return -1;

    bzero(&group_conf,sizeof(struct _select_def));

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos=1;
    group_conf.page_pos=1;

    group_conf.on_select = set_smsg_select;
    group_conf.show_data = set_smsg_show;
    group_conf.pre_key_command = set_smsg_prekey;
    group_conf.show_title = set_smsg_refresh;
    group_conf.get_data = set_smsg_getdata;
    group_conf.key_command = set_smsg_key;


    bzero(s_m, sizeof(struct smsmsg) * BBS_PAGESIZE);
    group_conf.item_count = count_sql_smsmsg(getCurrentUser()->userid, NULL, 0, 0, -1, 0, NULL, getSession());
    i = get_sql_smsmsg(s_m, getCurrentUser()->userid, NULL, 0, 0, -1, 0, 0, BBS_PAGESIZE, NULL,sm_desc, getSession());

    if (i <= 0) {
        free(s_m);
        return -1;
    }

    clear();
    list_select_loop(&group_conf);

    for (i=0; i<sm_num; i++) {
        if (s_m[i].context) free(s_m[i].context);
    }

    free(pts);
    free(s_m);
    s_m = NULL;

    chk_smsmsg(1, getSession());

    return 1;
}
Ejemplo n.º 4
0
int set_clock(void){
	struct _select_def group_conf;
	int i;
	POINT *pts;
#ifdef NEW_HELP
	int oldhelpmode=helpmode;
#endif

	clock_data = (struct clock_struct *) malloc(sizeof(struct clock_struct) * MAX_CLOCK_DEF);
	if(clock_data==NULL) return -1;

    if(init_clock_data()==0) {
        free(clock_data);
        clock_data = NULL;
        return -2;
    }

	bzero(&group_conf,sizeof(struct _select_def));
	group_conf.item_count = clock_total;

    //TODO: 窗口大小动态改变的情况?这里有bug
    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
	group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_LOOP | LF_MULTIPAGE;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
	group_conf.title_pos.x = 0;
	group_conf.title_pos.y = 0;
	group_conf.pos=1;
	group_conf.page_pos=1;

	group_conf.on_select = set_clock_select;
	group_conf.show_data = set_clock_show;
	group_conf.pre_key_command = set_clock_prekey;
	group_conf.show_title = set_clock_refresh;
	group_conf.get_data = set_clock_getdata;
	group_conf.key_command = set_clock_key;

#ifdef NEW_HELP
	helpmode=HELP_TIME;
#endif
	list_select_loop(&group_conf);
#ifdef NEW_HELP
	helpmode=oldhelpmode;
#endif
	save_clock_data();
	free(pts);
	free(clock_data);
	clock_data=NULL;

	return 1;
}
Ejemplo n.º 5
0
Archivo: tmpl.c Proyecto: zhouqt/kbs
static int tmpl_select(struct _select_def *conf)
{

    int i;
    POINT *pts;
    struct _select_def grouplist_conf;

    clear();
    t_now = conf->pos - 1;

    if (ptemplate[t_now].tmpl->content_num == 0) {
        char ans[3];
        clear();
        getdata(t_lines - 1, 0, "本模板现在没有内容,需要现在增加吗(Y/N)? [N]: ", ans, sizeof(ans), DOECHO, NULL, true);
        if (ans[0] != 'Y' && ans[0] != 'y') {
            return SHOW_REFRESH;
        }
        if (content_add() < 0) {
            return SHOW_REFRESH;
        }
    }

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    bzero(&grouplist_conf, sizeof(struct _select_def));

    grouplist_conf.item_count = ptemplate[t_now].tmpl->content_num;
    grouplist_conf.item_per_page = BBS_PAGESIZE;
    /*
     * 加上 LF_VSCROLL 才能用 LEFT 键退出
     */
    grouplist_conf.flag = LF_VSCROLL | LF_BELL | LF_LOOP | LF_MULTIPAGE;
    grouplist_conf.prompt = "◆";
    grouplist_conf.item_pos = pts;
    grouplist_conf.title_pos.x = 0;
    grouplist_conf.title_pos.y = 0;
    grouplist_conf.pos = 1;     /* initialize cursor on the first mailgroup */
    grouplist_conf.page_pos = 1;        /* initialize page to the first one */

    grouplist_conf.show_data = content_show;
    grouplist_conf.pre_key_command = tmpl_prekey;
    grouplist_conf.key_command = content_key;
    grouplist_conf.show_title = content_refresh;
    grouplist_conf.get_data = content_getdata;

    list_select_loop(&grouplist_conf);

    free(pts);

    t_now = 0;

    return SHOW_REFRESH;
}
Ejemplo n.º 6
0
int define_key(void)
{
    struct _select_def group_conf;
    struct key_struct key;
    POINT *pts;
    int i;

    skip_key = 1;

    if (keymem_total==0) {
        key.key = 'A';
        key.mapped[0] = 'A';
        key.mapped[1] = 0;
        key.status[0] = 0;
        add_key(&key);
        ask_define();
    }

    bzero(&group_conf, sizeof(struct _select_def));
    group_conf.item_count = keymem_total;

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    group_conf.item_per_page = BBS_PAGESIZE;
    /*
     * 加上 LF_VSCROLL 才能用 LEFT 键退出
     */
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_LOOP | LF_MULTIPAGE;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
//    group_conf.arg = &arg;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos = 1;         /* initialize cursor on the first mailgroup */
    group_conf.page_pos = 1;    /* initialize page to the first one */

    group_conf.on_select = set_keydefine_select;
    group_conf.show_data = set_keydefine_show;
    group_conf.pre_key_command = set_keydefine_prekey;
    group_conf.key_command = set_keydefine_key;
    group_conf.show_title = set_keydefine_refresh;
    group_conf.get_data = set_keydefine_getdata;

    list_select_loop(&group_conf);
    save_key();
    free(pts);
    skip_key = 0;

    return 0;
}
Ejemplo n.º 7
0
int simple_select_loop(const struct _select_item* item_conf,int flag,int titlex,int titley,union _select_return_value* ret)
{
    struct _select_def simple_conf;
    struct _simple_select_arg arg;
    POINT *pts;
    int i;
    int numbers;

    for (numbers = 0; item_conf[numbers].x!=-1; numbers++);
    pts = (POINT *) malloc(sizeof(POINT) * numbers);

    for (i= 0; i<numbers; i++) {
        pts[i].x = item_conf[i].x;
        pts[i].y = item_conf[i].y;
    }

    arg.items=item_conf;
    arg.flag=flag;
    
    bzero((char *) &simple_conf, sizeof(struct _select_def));
    simple_conf.item_count = numbers;
    simple_conf.item_per_page = numbers;
    simple_conf.flag = LF_BELL | LF_LOOP; /*|LF_HILIGHTSEL;*/
    simple_conf.prompt = "◆";
    simple_conf.item_pos = pts;
    simple_conf.arg = &arg;
    simple_conf.title_pos.x = titlex;
    simple_conf.title_pos.y = titley;
    simple_conf.pos = numbers;
    simple_conf.on_select = simple_onselect;
    simple_conf.show_data = simple_show;
    simple_conf.key_command = simple_key;

    i=list_select_loop(&simple_conf);
    free(pts);

    if ((flag&SIF_SINGLE)&&(i==SHOW_SELECT))
    	return simple_conf.pos;
    return 0;
}
Ejemplo n.º 8
0
int al_read(void){
	struct _select_def group_conf;
	int i;
	POINT *pts;
	
	al_dest[0]=0;
	al_group[0]=0;

	a_l = (struct addresslist *) malloc( sizeof(struct addresslist) * BBS_PAGESIZE );
	if( a_l == NULL)
		return -1;
	
	bzero(&group_conf,sizeof(struct _select_def));

    //TODO: 窗口大小动态改变的情况?这里有bug
    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
	group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
	group_conf.title_pos.x = 0;
	group_conf.title_pos.y = 0;
	group_conf.pos=1;
	group_conf.page_pos=1;

	group_conf.on_select = set_al_select;
	group_conf.show_data = set_al_show;
	group_conf.pre_key_command = set_al_prekey;
	group_conf.show_title = set_al_refresh;
	group_conf.get_data = set_al_getdata;
	group_conf.key_command = set_al_key;


	bzero( a_l, sizeof(struct addresslist) * BBS_PAGESIZE );
	group_conf.item_count = count_sql_al(getCurrentUser()->userid, al_dest, al_group, NULL);
	i = get_sql_al(a_l, getCurrentUser()->userid, al_dest, al_group, 0, BBS_PAGESIZE, al_order, NULL);
	
	if(i < 0){
		free(pts);
		free(a_l);
		return -1;
	}
	if(i == 0){
		if(!add_addresslist(NULL)){
			free(pts);
			free(a_l);
			return -1;
		}
		i = get_sql_al(a_l, getCurrentUser()->userid, al_dest, al_group, 0, BBS_PAGESIZE, al_order, NULL);
		group_conf.item_count = 1;
	}

	if(i <= 0){
		free(pts);
		free(a_l);
		return -1;
	}

	clear();
	list_select_loop(&group_conf);

	for(i=0;i<al_num;i++){
		if( a_l[i].memo ) free(a_l[i].memo);
	}

	free(pts);
	free(a_l);
	a_l = NULL;

	return 1;
}
Ejemplo n.º 9
0
int newhelp_loop(int mode)
{

    struct _select_def group_conf;
    int i;
    POINT *pts;

    if (mode < 0 || mode > NUMHELPMODE)
        return -1;

    help_search[0]=0;
    bzero(&group_conf,sizeof(struct _select_def));

    s_help = (struct helps *)malloc(sizeof(struct helps) * BBS_PAGESIZE);
    if (s_help == NULL)
        return -1;
    bzero(s_help, sizeof(struct helps)*BBS_PAGESIZE);

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.arg = & mode;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos=1;
    group_conf.page_pos=1;

    group_conf.on_select = help_select;
    group_conf.show_data = help_show;
    group_conf.pre_key_command = help_prekey;
    group_conf.show_title = help_refresh;
    group_conf.get_data = help_getdata;
    group_conf.key_command = help_key;

    group_conf.item_count = count_help(mode);

    if (group_conf.item_count<=0) {
        free(pts);
        free(s_help);
        if (HAS_PERM(getCurrentUser(), PERM_SYSOP)) {
            add_help(mode, -1);
        } else {
            clear();
            prints("现在没有该状态下帮助,或者系统出错\n");
            pressanykey();
        }
        return -1;
    }

    i = get_help(s_help, mode, 0, BBS_PAGESIZE);

    if (i<=0) {
        free(pts);
        free(s_help);
        clear();
        prints("现在没有该状态下帮助,或者系统出错\n");
        pressanykey();
        return -1;
    }

    help_num = i;
    clear();
    list_select_loop(&group_conf);

    for (i=0; i< help_num; i++) {
        if (s_help[i].content) free(s_help[i].content);
    }
    free(pts);
    free(s_help);
    s_help=NULL;
    help_num=0;

    return 1;

}
Ejemplo n.º 10
0
int set_modes(int *res)
{
    struct _select_def group_conf;
    POINT *pts;
    char *s;
    int i,j,n;

    n=1; modest=0;
    modes[0][0]=0;
    modes[0][1]=res[0]==0;
    for (i=0; i<200; i++) {
        s=ModeType(i);
        if (s[0]&&!strchr(s,'?')&&!strchr(s,'W')) {
            modes[n][0]=i;
            modes[n][1]=0;
            if (res[0]!=-1)
                for (j=0; j<10; j++) {
                    if (!res[j]) break;
                    if (res[j]==i) {
                        modes[n][1]=1;
                        modest++;
                        break;
                    }
                }
            n++;
        }
    }
    bzero(&group_conf, sizeof(struct _select_def));
    group_conf.item_count = n;

    //TODO: 窗口大小动态改变的情况?这里有bug
    pts = (POINT *) malloc(sizeof(POINT) * n);
    for (i = 0; i < n; i++) {
        pts[i].x = 2+20*(i/BBS_PAGESIZE);
        pts[i].y = i%BBS_PAGESIZE + 3;
    }
    group_conf.item_per_page = n;
    /*
     * 加上 LF_VSCROLL 才能用 LEFT 键退出
     */
    group_conf.flag = LF_BELL | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
//    group_conf.arg = &arg;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos = 1;         /* initialize cursor on the first mailgroup */
    group_conf.page_pos = 1;    /* initialize page to the first one */

    group_conf.show_data = set_modes_show;
    group_conf.pre_key_command = set_modes_prekey;
    group_conf.key_command = set_modes_key;
    group_conf.show_title = set_modes_refresh;
    group_conf.get_data = set_modes_getdata;

    list_select_loop(&group_conf);
    free(pts);
    if (modes[0][1]) res[0]=0;
    else if (modest==0) res[0]=-1;
    else {
        j=0;
        for (i=1; i<n; i++)
            if (modes[i][1]) {
                res[j]=modes[i][0];
                j++;
            }
        if (j<10) res[j]=0;
    }

    return 0;
}
Ejemplo n.º 11
0
Archivo: tmpl.c Proyecto: zhouqt/kbs
int m_template()
{
    int i;
    POINT *pts;
    struct _select_def grouplist_conf;

    if (!chk_currBM(currBM, getCurrentUser())) {
        return DONOTHING;
    }

    if (tmpl_init(1) < 0)
        return FULLUPDATE;

    if (template_num == 0) {
        char ans[3];
        clear();
        getdata(t_lines - 1, 0, "本版现在没有模板,需要现在增加吗(Y/N)? [N]: ", ans, sizeof(ans), DOECHO, NULL, true);
        if (ans[0] != 'Y' && ans[0] != 'y') {
            tmpl_free();
            return FULLUPDATE;
        }
        if (tmpl_add() < 0) {
            tmpl_free();
            return FULLUPDATE;
        }
    }

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    bzero(&grouplist_conf, sizeof(struct _select_def));

    grouplist_conf.item_count = template_num;
    grouplist_conf.item_per_page = BBS_PAGESIZE;
    /*
     * 加上 LF_VSCROLL 才能用 LEFT 键退出
     */
    grouplist_conf.flag = LF_VSCROLL | LF_BELL | LF_LOOP | LF_MULTIPAGE;
    grouplist_conf.prompt = "◆";
    grouplist_conf.item_pos = pts;
    grouplist_conf.title_pos.x = 0;
    grouplist_conf.title_pos.y = 0;
    grouplist_conf.pos = 1;     /* initialize cursor on the first mailgroup */
    grouplist_conf.page_pos = 1;        /* initialize page to the first one */

    grouplist_conf.show_data = tmpl_show;
    grouplist_conf.pre_key_command = tmpl_prekey;
    grouplist_conf.key_command = tmpl_key;
    grouplist_conf.show_title = tmpl_refresh;
    grouplist_conf.get_data = tmpl_getdata;
    grouplist_conf.on_select = tmpl_select;

    list_select_loop(&grouplist_conf);

    free(pts);
    tmpl_free();

    return FULLUPDATE;

}
Ejemplo n.º 12
0
Archivo: tmpl.c Proyecto: zhouqt/kbs
int choose_tmpl(char *title, char *fname)
{
    POINT *pts;
    struct _select_def grouplist_conf;
    int i;

    if (tmpl_init(0) < 0)
        return  -1;

    if (template_num == 0) {
        clear();
        move(3,0);
        prints("本版没有模板可供使用");
        pressanykey();
        tmpl_free();
        return  -1;
    }

    t_now = 0;

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    bzero(&grouplist_conf, sizeof(struct _select_def));

    grouplist_conf.arg = fname;
    grouplist_conf.item_count = template_num;
    grouplist_conf.item_per_page = BBS_PAGESIZE;
    grouplist_conf.flag = LF_VSCROLL | LF_BELL | LF_LOOP | LF_MULTIPAGE;
    grouplist_conf.prompt = "◆";
    grouplist_conf.item_pos = pts;
    grouplist_conf.title_pos.x = 0;
    grouplist_conf.title_pos.y = 0;
    grouplist_conf.pos = 1;
    grouplist_conf.page_pos = 1;

    grouplist_conf.show_data = tmpl_show;
    grouplist_conf.pre_key_command = tmpl_prekey;
    grouplist_conf.key_command = choose_tmpl_key;
    grouplist_conf.show_title = choose_tmpl_refresh;
    grouplist_conf.get_data = choose_tmpl_getdata;
    grouplist_conf.on_select = choose_tmpl_select;

    list_select_loop(&grouplist_conf);

    if (t_now > 0) {
        if (choose_tmpl_post(title, fname) < 0)
            t_now = 0;
    }

    free(pts);
    tmpl_free();

    if (t_now > 0) {
        t_now = 0;
        return 0;
    }
    return -1;
}