Esempio n. 1
0
/* 進站水球宣傳 */
int
m_loginmsg(void)
{
  char msg[100];
  move(21,0);
  clrtobot();
  if(SHM->loginmsg.pid && SHM->loginmsg.pid != currutmp->pid)
    {
      outs("目前已經有以下的 進站水球設定請先協調好再設定..");
      getmessage(SHM->loginmsg);
    }
  getdata(22, 0,
     "進站水球:本站活動,不干擾使用者為限,設定者離站自動取消,確定要設?(y/N)",
          msg, 3, LCECHO);

  if(msg[0]=='y' &&

     getdata_str(23, 0, "設定進站水球:", msg, 56, DOECHO, SHM->loginmsg.last_call_in))
    {
          SHM->loginmsg.pid=currutmp->pid; /*站長不多 就不管race condition */
          strlcpy(SHM->loginmsg.last_call_in, msg, sizeof(SHM->loginmsg.last_call_in));
          strlcpy(SHM->loginmsg.userid, cuser.userid, sizeof(SHM->loginmsg.userid));
    }
  return 0;
}
Esempio n. 2
0
BLAPI_PROTO
bl_getstr(lua_State* L)
{
    int y, x;
    // TODO not using fixed length here?
    char buf[PATHLEN] = "";
    int len = 2, echo = 1;
    int n = lua_gettop(L);
    const char *pmsg = NULL;

    if (n > 0)
        len = lua_tointeger(L, 1);
    if (n > 1)
        echo = lua_tointeger(L, 2);
    if (n > 2)
        pmsg = lua_tostring(L, 3);

    if (len < 2)
        len = 2;
    if (len >= (int)sizeof(buf))
        len = sizeof(buf) - 1;
    /*
     * this part now done in getdata_str
    if (pmsg && *pmsg)
    {
        strlcpy(buf, pmsg, sizeof(buf));
    }
    */

    // TODO process Ctrl-C here
    getyx(&y, &x);
    if (!pmsg) pmsg = "";
    len = getdata_str(y, x, NULL, buf, len, echo, pmsg);
    if (len <= 0)
    {
        len = 0;
        // check if we got Ctrl-C? (workaround in getdata)
        // TODO someday write 'ungetch()' in io.c to prevent
        // such workaround.
        if (buf[1] == Ctrl('C'))
        {
            vkey_purge();
            blrt.abort = 1;
            return lua_yield(L, 0);
        }
        lua_pushstring(L, "");
    }
    else
    {
        lua_pushstring(L, buf);
    }
    // return len ? 1 : 0;
    return 1;
}
Esempio n. 3
0
int author_backward(int ent, FILEHEADER* finfo, char *direct)
{
	int i;

	if (!getdata_str(b_line, 0, "[往前找作者]: ", sbuf, sizeof(sbuf), ECHONOSP,
		     sbuf))
	{
		return C_FOOT;
	}
	if ((i = search_article(direct, ent, sbuf, 'a', NULL)) == -1)
	{
		msg("找不到!");
		getkey();
		return C_FOOT;
	}
	*gol_ccur = i;
	return C_MOVE;
}
Esempio n. 4
0
int more(char *filename, BOOL promptend)
{
	FILE *fp;
	int chkey;
	int viewed, numbytes;
	int i, lines;
	int pageno, pagebreaks[MAXPAGE];
	struct stat st;
	char buf[512];
	BOOL dojump = FALSE;
	int jumpto = 0, dummy;


	if ((fp = fopen(filename, "r")) == NULL)
		return -1;

	if (fstat(fileno(fp), &st) == -1)
		return -1;

	i = 0;
	lines = 0;
	viewed = 0;
	pageno = 0;
	pagebreaks[0] = 0;

	clear();

 	/* read a line & process it until end of it */
	while ((numbytes = readln(buf, sizeof(buf), fp)) != 0)
	{
		if (!dojump || (dojump && pageno < jumpto - 2))
		{
			/* sarek:06/09/2002:引言上色,修正加空白後的第二層引言上色判斷 */
			if ((buf[0] == '>' && buf[1] == ' ' && buf[2] == '>') ||
				(buf[0] == '>' && buf[1] == '>') ||
				(buf[0] == ':' && buf[1] == ' ' && buf[2] == ':') ||
				(buf[0] == ':' && buf[1] == ':') )
			{
				outs("");
				outs(buf);
				outs("");
			}
			else if (buf[0] == '>' || buf[0] == ':')
			{
				outs("");
				outs(buf);
				outs("");
			}
			else
			{
				outs(buf);
			}
		}

		viewed += numbytes;

		getyx(&i, &dummy);

		if (++lines == b_line)
		{
			if (++pageno < MAXPAGE)
				pagebreaks[pageno] = viewed;
			lines = 0;
		}

/*
		if (i == b_line)
*/
		if (i >= b_line)
		{
			if (dojump)
			{
				if (pageno < jumpto - 1)
					continue;
				dojump = FALSE;
			}

			move(b_line, 0);
			prints(_msg_more_1, (viewed * 100) / st.st_size, pageno);
			while ((chkey = igetkey()) != EOF)
			{
#if 1
				if (msqrequest)
				{
					msqrequest = FALSE;
					msq_reply();
					continue;
				}
				if (chkey == CTRL('R'))
					msq_reply();
				else
#endif
				if (chkey == ' ' || chkey == KEY_RIGHT || chkey == KEY_PGDN)
				{
					clear();
					i = 0;
					break;
				}
				else if (chkey == 'q' || chkey == KEY_LEFT)
				{
					move(b_line, 0);
					clrtoeol();
					fclose(fp);
					return 0;
				}
				else if (chkey == '\r' || chkey == '\n' || chkey == KEY_DOWN)
				{
					scroll();
					move(b_line - 1, 0);
					clrtoeol();
					refresh();
					i = b_line - 1;
					lines--;
					break;
				}
				else if (chkey == 'b' || chkey == KEY_PGUP)
				{
					if (pageno > 1 && pageno <= MAXPAGE)
					{
						pageno -= 2;
						viewed = pagebreaks[pageno - 1];
						fseek(fp, viewed, SEEK_SET);
						clear();
						lines = 0;
						i = 0;
						break;
					}
				}
				else if (isdigit(chkey))
				{
					char nbuf[4];

					nbuf[0] = chkey;
					nbuf[1] = '\0';
					if (getdata_str(b_line, 0, "跳到第幾頁: ", nbuf, 4, ECHONOSP, nbuf))
					{
						dojump = TRUE;
						jumpto = atoi(nbuf);
						pageno = jumpto;
						viewed = pagebreaks[pageno];
						fseek(fp, viewed, SEEK_SET);
						clear();
						lines = 0;
						i = 0;
					}
					break;
				}
#if 0
				else if (chkey == '/')
				{
					char grepstr[60];
					long hit = 0;
					int cur_page = pageno + 1;
					int j = 0;

					if (!getdata(b_line, 0, "請輸入搜尋字串: ", grepstr, sizeof(grepstr), XECHO, NULL))
						break;

					while ((numbytes = readln(fp, buf)))
					{
						viewed += numbytes;
						if (strstr(buf, grepstr))
						{
							hit = ftell(fp) - numbytes;
							break;
						}
						if (++j == t_lines - 1)
						{
							if (cur_page < MAXPAGE - 1)
								pagebreaks[cur_page + 1] = viewed - numbytes;
						}
						else if (j == t_lines)
						{
							cur_page++;
							j = 0;
						}
					}
					if (hit)
					{
						pageno = cur_page;
						viewed = pagebreaks[pageno];
						fseek(fp, viewed, SEEK_SET);
						clear();
						i = linectr = 0;
						numbytes = readln(fp, buf);
					}
					else
					{
						move(b_line, 0);
						clrtoeol();
						prints("--More--(%d%% p.%d) [→]:下一頁,[↓]:下一列,[B]:上一頁,[←][q]:中斷 more        ", (viewed * 100) / st.st_size, pageno + 1);
					}
					break;
				}
#endif
			}	/* while */
		}		/* if */
	}			/* while */

	fclose(fp);
	if (promptend && st.st_size > 0)	/* lthuang */
		pressreturn();
	return 0;
}