コード例 #1
0
ファイル: rkpty.c プロジェクト: DavidMulder/heimdal
static void
parse_configuration(const char *fn)
{
    struct command *c;
    char s[1024];
    char *str;
    unsigned int lineno = 0;
    FILE *cmd;

    cmd = fopen(fn, "r");
    if (cmd == NULL)
	err(1, "open: %s", fn);

    while (fgets(s, sizeof(s),  cmd) != NULL) {

	s[strcspn(s, "#\n")] = '\0';
	lineno++;

	c = calloc(1, sizeof(*c));
	if (c == NULL)
	    errx(1, "malloc");

	c->lineno = lineno;
	(*next) = c;
	next = &(c->next);

	if ((str = iscmd(s, "expect ")) != NULL) {
	    c->type = CMD_EXPECT;
	    c->str = str;
	} else if ((str = iscmd(s, "send ")) != NULL) {
	    c->type = CMD_SEND;
	    c->str = str;
	} else if ((str = iscmd(s, "password ")) != NULL) {
	    c->type = CMD_PASSWORD;
	    c->str = str;
	} else
	    errx(1, "Invalid command on line %d: %s", lineno, s);
    }

    fclose(cmd);
}
コード例 #2
0
ファイル: treat_cmd.c プロジェクト: Yanumaru/asm_corewar
void	search_cmd(t_group *all)
{
	t_list	*tmp;

	tmp = all->l;
	while (tmp)
	{
		if (iscmd(tmp->line))
			treat_cmd(tmp->line, all, tmp->nb_line);
		tmp = tmp->next;
	}
}
コード例 #3
0
ファイル: batch.c プロジェクト: dsheeler/krad_radio
void krs_run (kr_shell_t *kr_shell,char **cmdsplit) {

	int i,j;
	int found = 0;
	int m;
	kr_batch_t **batches = kr_shell->batches;
	kr_batch_t *batch;
	char **splitted;
	char *sysname = kr_shell->sysname;

	for (i=0;i<kr_shell->nbatches;i++) {

		batch = batches[i];

		if (!strcmp (cmdsplit[1],batch->name)) {

			for (j=0;j<batch->ncmds;j++) {

				splitted = split (batch->cmds[j],&m);

				if (iscmd (splitted[0],kr_shell)) {
					krad_shell_cmd (kr_shell,sysname,m,splitted);
				}
				else {

          // cmd not valid 
					char *errstr1 = " is not a valid command";
					char *errstr = calloc (strlen (errstr1)+strlen (splitted[0]) + 1,sizeof (char));
					sprintf (errstr,"%s%s",splitted[0],errstr1);
					shell_print (errstr);
					free (errstr);
				}

				free (splitted);
			}

			found++;
		}

	}

	if (!found) {
		shell_print ("No batch with that name");
	}
}
コード例 #4
0
ファイル: batch.c プロジェクト: dsheeler/krad_radio
void krs_replay (kr_shell_t *kr_shell,char **cmdsplit) {
	int p;
	int m;
	char **splitted;
	int to = atoi (cmdsplit[1]);
	history_t *history = kr_shell->history;
	char **his = history->his;
	int h = kr_shell->cmds;

	char *sysname = kr_shell->sysname;

	if (to <= h-1) {

		for (p=to+1;p>1;p--) {

			splitted = split (his[h-p],&m);

			if (iscmd (splitted[0],kr_shell)) {
				krad_shell_cmd (kr_shell,sysname,m,splitted);
			}
			else {

                  // cmd not valid 
				char *errstr1 = " is not a valid command";
				char *errstr = calloc (strlen (errstr1)+strlen (splitted[m-1]) + 1,sizeof (char));
				sprintf (errstr,"%s%s",splitted[m-1],errstr1);
				shell_print (errstr);
				free (errstr);

			}

			free (splitted);

		}

	}
}
コード例 #5
0
ファイル: wiki.c プロジェクト: AustenConrad/plan-9
/* return 1 if handled, 0 otherwise */
int
wikicmd(Wiki *w, char *s)
{
	char *p;
	s = skip(s, "");

	if(iscmd(s, "Del")){
		if(windel(w->win, 0))
			w->dead = 1;
		return 1;
	}
	if(iscmd(s, "New")){
		wikinew(skip(s, "New"));
		return 1;
	}
	if(iscmd(s, "History"))
		return wikiload(w, "history.txt");
	if(iscmd(s, "Diff"))
		return wikidiff(w);
	if(iscmd(s, "Get")){
		if(winisdirty(w->win) && !w->win->warned){
			w->win->warned = 1;
			fprint(2, "%s/%s modified\n", dir, w->arg);
		}else{
			w->win->warned = 0;
			wikiget(w);
		}
		return 1;
	}
	if(iscmd(s, "Put")){
		if((p=strchr(w->arg, '/')) && p[1]!='\0')
			fprint(2, "%s/%s is read-only\n", dir, w->arg);
		else
			wikiput(w);
		return 1;
	}
	return 0;
}
コード例 #6
0
ファイル: server.c プロジェクト: xhbang/network-exercise
void accept_cli(threadargs *newargs)
{
  LList *userlist=newargs->list;
  int cli_socket=newargs->sock;
  int cli_sock2;
  int recvn;	//num of recv bytes
  char buf[bufsize+1]="";
  char buf2[bufsize+1]="";
  char cmd;
  client newcli;
  client lastuser;	//the user which client talk to last time
  bzero(&newcli,sizeof(client));
  bzero(&lastuser,sizeof(client));
  if(-1==Recv(cli_socket,buf))
    pthread_exit(NULL);
  printf("%s",buf);
  if(-1==Send(cli_socket,"Server OCP v0.0.1\n"))
    pthread_exit(NULL);
  bzero(buf,bufsize);
  if(-1==Recv(cli_socket,buf))
    pthread_exit(NULL);
  Rtrim(buf);
  while(useratlist(userlist,buf)==0) //username has been used
  {
    if(-1==Send(cli_socket,":x"))
      pthread_exit(NULL);
    bzero(buf,bufsize);
    if(-1==Recv(cli_socket,buf))
      pthread_exit(NULL);

    Rtrim(buf);
  }
  Send (cli_socket,"Longin Successfully\n");

  strncpy(newcli.nick,buf,strlen(buf));
  newcli.sock=cli_socket;
  ListInsert(userlist,newcli);


  while(1)
  {
    LNode *node=userlist->head->next; //use in :a
    bzero(buf,bufsize);
    if(Recv(cli_socket,buf)==-1)	//client offline
    {
      ListDelete(userlist,cli_socket);
      pthread_exit(NULL);
    }
    if((cmd=iscmd(buf))==0)	//if message body contains only message(not have a command)
    {
      if(useratlist(userlist,lastuser.nick)==0)

      {
        cli_sock2=lastuser.sock;
        domessage(buf2,newcli.nick,buf);
        if(-1==Send(cli_sock2,buf2))
          pthread_exit(NULL);
      }

      else
      {
        if(-1==Send(cli_socket,"The user you want to talk isn't online\n"))
          pthread_exit(NULL);
      }
      continue;
    }
    switch(cmd)
    {
    case 'l':
      bzero(buf,bufsize);
      LNode *user=userlist->head->next;
      while(user!=NULL)
      {
        strcat(buf,user->e.nick);
        strcat(buf,"\n");
        user=user->next;
      }

      if(-1==Send(cli_socket,buf))
        pthread_exit(NULL);
      break;
    case 'u':	//client change user which will talk to
      if(getuser(buf,lastuser.nick,userlist)!=-1)	//buf client's message //buf2 username
      {cli_sock2=findclientsock(userlist,lastuser.nick);
        lastuser.sock=cli_sock2;
        if(getthird(buf)!=NULL)
        {
          domessage(buf2,newcli.nick,getthird(buf));
          if(-1==Send(cli_sock2,buf2))
            pthread_exit(NULL);
        }
      }
      else
      {
        if(-1==Send(cli_socket,"You doesn't specify a user,or the user you want to talk to isn't online\n"))
          pthread_exit(NULL);
      }
      break;
    case 'q':	//client quit
      if(-1==Send(cli_socket,buf))
        pthread_exit(NULL);
      ListDelete(userlist,cli_socket);
      close(cli_socket);
      pthread_exit(NULL);
      break;
    case 'a':	//client talk to all user

      while(node!=NULL)
      {
        client user=node->e;

        cli_sock2=user.sock;
        if (cli_sock2!=cli_socket)	//don't send the message to your
          {   if(getsecond(buf)!=NULL)	//if the message body only contains the :a string

            domessage(buf2,newcli.nick,getsecond(buf));
          if(-1==Send(cli_sock2,buf2))
            pthread_exit(NULL);
        }

        node=node->next;
      }
      break;
    default :
      if(-1==Send(cli_socket,"Sever can't recognize your command\n"))
        pthread_exit(NULL);

    }
  }

}
コード例 #7
0
ファイル: input.c プロジェクト: 151706061/nsis-chinese
/*
 * Read a token from the input file, in the normal way (`normal' in
 * the sense that code paragraphs work a different way).
 */
token get_token(input * in)
{
  int c;
  int nls;
  token ret;
  rdstring rs = { 0, 0, NULL };
  filepos cpos;

  ret.cmd = c__invalid;
  ret.aux = FALSE;
  ret.text = NULL;              /* default */
  c = get(in, &cpos);
  ret.pos = cpos;
  if (iswhite(c))
  {                             /* tok_white or tok_eop */
    nls = 0;
    do
    {
      if (isnl(c))
        nls++;
    }
    while ((c = get(in, &cpos)) != EOF && iswhite(c));
    if (c == EOF)
    {
      ret.type = tok_eof;
      return ret;
    }
    unget(in, c, &cpos);
    ret.type = (nls > 1 ? tok_eop : tok_white);
    return ret;
  } else if (c == EOF)
  {                             /* tok_eof */
    ret.type = tok_eof;
    return ret;
  } else if (c == '\\')
  {                             /* tok_cmd */
    c = get(in, &cpos);
    if (c == '-' || c == '\\' || c == '_' ||
        c == '#' || c == '{' || c == '}')
    {
      /* single-char command */
      rdadd(&rs, (wchar_t)c);
    } else if (c == 'u')
    {
      int len = 0;
      do
      {
        rdadd(&rs, (wchar_t)c);
        len++;
        c = get(in, &cpos);
      }
      while (ishex(c) && len < 5);
      unget(in, c, &cpos);
    } else if (iscmd(c))
    {
      do
      {
        rdadd(&rs, (wchar_t)c);
        c = get(in, &cpos);
      }
      while (iscmd(c));
      unget(in, c, &cpos);
    }
    /*
     * Now match the command against the list of available
     * ones.
     */
    ret.type = tok_cmd;
    ret.text = ustrdup(rs.text);
    match_kw(&ret);
    sfree(rs.text);
    return ret;
  } else if (c == '{')
  {                             /* tok_lbrace */
    ret.type = tok_lbrace;
    return ret;
  } else if (c == '}')
  {                             /* tok_rbrace */
    ret.type = tok_rbrace;
    return ret;
  } else
  {                             /* tok_word */
    /*
     * Read a word: the longest possible contiguous sequence of
     * things other than whitespace, backslash, braces and
     * hyphen. A hyphen terminates the word but is returned as
     * part of it; everything else is pushed back for the next
     * token. The `aux' field contains TRUE if the word ends in
     * a hyphen.
     */
    ret.aux = FALSE;            /* assumed for now */
    while (1)
    {
      if (iswhite(c) || c == '{' || c == '}' || c == '\\' || c == EOF)
      {
        /* Put back the character that caused termination */
        unget(in, c, &cpos);
        break;
      } else
      {
        rdadd(&rs, (wchar_t)c);
        if (c == '-')
        {
          ret.aux = TRUE;
          break;                /* hyphen terminates word */
        }
      }
      c = get(in, &cpos);
    }
    ret.type = tok_word;
    ret.text = ustrdup(rs.text);
    sfree(rs.text);
    return ret;
  }
}
コード例 #8
0
ファイル: command.c プロジェクト: bju2000/kernel_lge_msm8994
void anal_command(int argc, char *argv[])
{
    if(iscmd("he"))                 Mon_help_command();
    else if(iscmd("?"))             Mon_help_command();
    else if(iscmd("help"))          Mon_help_command();

    else if(iscmd("brd"))        mmi_bbm_read(argc, argv);
    else if(iscmd("bwr"))        mmi_bbm_write(argc, argv);
    else if(iscmd("wrd"))        mmi_bbm_wread(argc, argv);
    else if(iscmd("wwr"))        mmi_bbm_wwrite(argc, argv);
    else if(iscmd("lrd"))        mmi_bbm_lread(argc, argv);
    else if(iscmd("lwr"))        mmi_bbm_lwrite(argc, argv);

    else if(iscmd("verify"))    mmi_bbm_verify(argc, argv);
    else if(iscmd("iverify"))    mmi_bbm_i2c_verify(argc, argv);

    else if(iscmd("tuner"))        mmi_tuner_set(argc, argv);

    else if(iscmd("reset"))        mmi_bbm_reset_cmd(argc, argv);
    else if(iscmd("init"))        mmi_bbm_init_cmd(argc, argv);

    else if(iscmd("ird"))        mmi_i2c_read_cmd(argc, argv);
    else if(iscmd("iwr"))        mmi_i2c_write_cmd(argc, argv);

    else if(iscmd("scan"))        mmi_scan_cmd(argc, argv);
    else if(iscmd("dm"))        mmi_dm_cmd(argc, argv);
    else if(iscmd("sig"))        mmi_sig_cmd(argc, argv);
    else if(iscmd("ptcheck"))        mmi_ptcheck_cmd(argc, argv);
    else if(iscmd("data_dump"))    mmi_data_dump_cmd(argc, argv);
    else if(iscmd("exit"))        mmi_exit_cmd(argc, argv);

    else print_log("\nNo such command - type help\n");
}
コード例 #9
0
/**
	Send the actual command to the radio.  The data is passed to us
	in a list of strings.  We go through each string, add all the hex
	numbers into a long string and total their values to use in the
	checksum.  (We use them in a string because it's easier to enter
	them into maps and other info as humans and it lets us easily print
	them out for reference, as well as defining one standard way to store
	them.)
	@param inlist list of different hex strings to send to the radio
*/
void HDCommands::sendcommand(list<string> inlist) {//private
	int msgout = 0, msglen = 0;
	char byte;
	char hbyte [10];
	int dec, count = 0, csum = 0;
	string cmd = "", ref = "", line;
	list<int> iout;
	list<string>::iterator x;

	for (x = inlist.begin(); x != inlist.end(); ++x) {
		line = *x;
		istringstream iss(line);
		do {
			dec = -1;
			iss >> hex >> dec;
			if (dec < 0) {
				break;
			}
			count++;
			csum += dec;
		} while (dec >= 0);
		ref += " ";
		ref += line;
	}
	csum += count;
	msglen = count + 3;
	sprintf(hbyte, "0x%2X", count);
	if (hbyte[2] == ' ')
		hbyte[2] = '0';
	line = ref;
// 	ref = hdconstants["begincommand"];
	ref = hdvals->getconstant("begincommand");
	istringstream istr(ref);
	istr >> hex >> dec;
	csum += dec;
	csum = csum % 256;
	ref += " ";
	ref += hbyte;
	ref += line;
	sprintf(hbyte, "0x%2X", csum);
	if (hbyte[2] == ' ')
		hbyte[2] = '0';
	ref += " ";
	ref += hbyte;
	istringstream iscmd(ref);
	do {
		dec = - 1;
		iscmd >> hex >> dec;
		if (dec < 0)
			break;
// 		cout << "\tConverting to byte: " << dec << endl;
		byte = dec;
		if (dec == 0x1B || (dec == 0xA4 && (msgout > 1 && msgout < msglen - 1))) {
// 			cout << "Sending escape byte.\n";
			ioport->hdsendbyte(0x1B);
			if (dec == 0xA4) {
				dec = 0x48;
				byte = dec;
// 				cout << "Changing value to: " << dec << endl;
			}
		}
		ioport->hdsendbyte(byte);
		msgout++;
	} while (dec >= 0);;
// 	cout << "Command sent\n";
	if (verbose) cout << "\tCommand bytes: " << ref << ", Length: " << msglen << endl;
	return;
}
コード例 #10
0
ファイル: vterm.c プロジェクト: italia389/MightEMacs
// Display a pop-up window and page it for the user.  If altmodeline is true, display buffer name and filename (only) on bottom
// mode line.  If endprompt is true, wait for user to press a key before returning (regardless of page size).  Current bindings
// (if any) for backPage, forwPage, backLine, and forwLine commands are recognized as well as 'b' (backward page), 'f' or space
// (forward page), 'u' (backward half page), 'd' (forward half page), 'g' (goto first page), 'G' (goto last page), ESC or 'q'
// (exit), and '?' (help).  Any non-navigation key gets pushed back into the input stream to be interpeted later as a command. 
// Return status.
int bpop(Buffer *bufp,bool altmodeline,bool endprompt) {
	Line *lnp1,*lnp,*lpmax;
	int crow;		// Current screen row number.
	int disprows;		// Total number of display rows.
	int halfpage;		// Rows in a half page.
	int n;			// Rows to move.
	ushort ek;		// Input extended key.
	char *strp,*strpz;	// Line text pointers.
	char *hprompt = NULL;	// Help prompt;
	bool firstpass = true;

	// Display special mode line if requested.
	if(altmodeline) {

		// Find last window on screen and rewrite its mode line.
		wupd_modeline(wnextis(NULL),bufp);
		}

	// Set up and display a pop-up "window".
	disprows = term.t_nrow - 2;

	// Check if buffer will fit on one page and if not, set lpmax to first line of last page.
	lpmax = NULL;
	n = 0;
	for(lnp = lforw(bufp->b_hdrlnp); lnp != bufp->b_hdrlnp; lnp = lforw(lnp)) {
		if(++n > disprows) {

			// Find beginning of last page.
			lpmax = bufp->b_hdrlnp;
			n = disprows;
			do {
				lpmax = lback(lpmax);
				} while(--n > 0);
			break;
			}
		}

	// Begin at the beginning.
	lnp1 = lforw(bufp->b_hdrlnp);
	halfpage = disprows / 2;
	n = 0;

	// Display a page (beginning at line lnp1 + n) and prompt for a naviagtion command.  Loop until exit key entered or
	// endprompt is false and buffer fits on one page (lpmax is NULL).
	for(;;) {
		lnp = lnp1;

		// Moving backward?
		if(n < 0) {
			do {
				// At beginning of buffer?
				if(lpmax == NULL || lnp1 == lforw(bufp->b_hdrlnp))
					break;

				// No, back up one line.
				lnp1 = lback(lnp1);
				} while(++n < 0);
			}

		// Moving forward?
		else if(n > 0) {
			do {
				// At end of buffer or max line?
				if(lpmax == NULL || lnp1 == bufp->b_hdrlnp || lnp1 == lpmax)
					break;

				// No, move forward one line.
				lnp1 = lforw(lnp1);
				} while(--n > 0);
			}

		// Illegal command?
		if(n != 0 && lnp1 == lnp)

			// Yes, ignore it.
			n = 0;
		else {
			// Found first row ... display page.
			lnp = lnp1;
			crow = 0;
			do {
				// At end of buffer?
				if(lnp == bufp->b_hdrlnp) {

					// Yes, erase remaining lines on physical screen.
					while(crow < disprows) {
						vtmove(crow,0);
						vteeol();
#if COLOR
						vscreen[crow]->v_rfcolor = gfcolor;
						vscreen[crow]->v_rbcolor = gbcolor;
#endif
						vscreen[crow]->v_left = FARRIGHT;
						vscreen[crow]->v_right = 0;
#if COLOR
						vscreen[crow++]->v_flags |= VFCHGD | VFCOLOR;
#else
						vscreen[crow++]->v_flags |= VFCHGD;
#endif
						}
					break;
					}

				// Update the virtual screen image for this line.  Characters past right edge of screen won't be
				// displayed, so ignore those.
				vtmove(crow,0);
				strpz = (strp = ltext(lnp)) + (lused(lnp) <= (int) term.t_ncol ? lused(lnp) : term.t_ncol);
				while(strp < strpz)
					vtputc(*strp++);
				vteeol();
#if COLOR
				vscreen[crow]->v_rfcolor = gfcolor;
				vscreen[crow]->v_rbcolor = gbcolor;
#endif
				vscreen[crow]->v_left = FARRIGHT;
				vscreen[crow]->v_right = 0;
#if COLOR
				vscreen[crow++]->v_flags |= VFCHGD | VFCOLOR;
#else
				vscreen[crow++]->v_flags |= VFCHGD;
#endif
				// On to the next line.
				lnp = lforw(lnp);
				} while(crow < disprows);

			// Screen is full.  Copy the virtual screen to the physical screen.
			if(pupd_all(false) != SUCCESS)
				return rc.status;

			// Bail out if called from terminp() and one-page buffer.
			if(firstpass && !endprompt && lpmax == NULL)
				goto uexit;
			firstpass = false;
			}

		// Display prompt.
		mlputs(MLHOME | MLFORCE,hprompt != NULL ? hprompt : lpmax == NULL || lnp1 == lpmax ? text201 : ": ");
													// "End: "
		if(TTflush() != SUCCESS)
			return rc.status;

		// Get response.
		for(;;) {
			// Get a keystroke and decode it.
			if(getkey(&ek) != SUCCESS)
				return rc.status;

			// Exit?
			if(ek == (CTRL | '[') || ek == 'q')
				goto uexit;

			// Forward whole page?
			if(ek == ' ' || ek == 'f' || iscmd(ek,forwPage)) {
				n = disprows - overlap;
				break;
				}

			// Forward half page?
			if(ek == 'd') {
				n = halfpage;
				break;
				}

			// Backward whole page?
			if(ek == 'b' || iscmd(ek,backPage)) {
				n = overlap - disprows;
				break;
				}

			// Backward half page?
			if(ek == 'u') {
				n = -halfpage;
				break;
				}

			// Forward a line?
			if(iscmd(ek,forwLine)) {
				n = 1;
				break;
				}

			// Backward a line?
			if(iscmd(ek,backLine)) {
				n = -1;
				break;
				}

			// First page?
			if(ek == 'g') {
				if(lpmax == NULL || lnp1 == lforw(bufp->b_hdrlnp))
					n = -1;			// Force beep.
				else {
					lnp1 = lforw(bufp->b_hdrlnp);
					n = 0;
					}
				break;
				}

			// Last page?
			if(ek == 'G') {
				if(lpmax == NULL || lnp1 == lpmax)
					n = 1;			// Force beep.
				else {
					lnp1 = lpmax;
					n = 0;
					}
				break;
				}

			// Help?
			if(ek == '?') {
				StrList msg;

				// Get string list...
				if(vopen(&msg,NULL,false) != 0)
					return vrcset();

				// build prompt...
				if(vputs(text202,&msg) != 0)
						// "(<SPC>,f"
					return vrcset();
				if(hkey(&msg,forwPage,0) != SUCCESS)
					return rc.status;
				if(vputs(text203,&msg) != 0)
						// ") +page (b"
					return vrcset();
				if(hkey(&msg,backPage,0) != SUCCESS)
					return rc.status;
				if(vputs(text204,&msg) != 0)
						// ") -page (d) +half (u) -half"
					return vrcset();
				if(hkey(&msg,forwLine,'+') != SUCCESS || hkey(&msg,backLine,'-') != SUCCESS)
					return rc.status;
				if(vputs(text206,&msg) != 0)
						// " (g) first (G) last (ESC,q) quit (?) help: "
					return vrcset();

				// and display it.
				if(vclose(&msg) != 0)
					return vrcset();
				mlputs(MLHOME | MLFORCE,msg.sl_vp->v_strp);
				}
			else {
				// Other key.  "Unget" the key for reprocessing and return.
				tungetc(ek);
				goto uexit;
				}
			}
		}
uexit:
	uphard();
	if(endprompt)
		mlerase(MLFORCE);

	return rc.status;
	}
コード例 #11
0
ファイル: news.c プロジェクト: carriercomm/plan9-gpl
int
acmecmd(Article *m, Window *w, char *s)
{
	int n;
	Biobuf *b;

//fprint(2, "cmd %s\n", s);

	s = skip(s, "");

	if(iscmd(s, "Del")){
		if(m == nil){	/* don't close dir until messages close */
			if(mlist != nil){
				ctlprint(mlist->w->ctl, "show\n");
				return 1;
			}
			if(windel(w, 0))
				threadexitsall(nil);
			return 1;
		}else{
			if(windel(w, 0))
				m->dead = 1;
			return 1;
		}
	}
	if(m==nil && iscmd(s, "More")){
		s = skip(s, "More");
		if(n = atoi(s))
			nshow = n;

		if(w->data < 0)
			w->data = winopenfile(w, "data");
		winsetaddr(w, "$", 1);
	
		fprint(w->ctl, "dirty\n");

		b = emalloc(sizeof(*b));
		Binit(b, w->data, OWRITE);
		lo = adddir(b, lo, 0, nshow);
		Bterm(b);
		free(b);		
		winclean(w);
		winsetaddr(w, ".,", 0);
	}
	if(m!=nil && !m->ispost && iscmd(s, "Headers")){
		m->headers = !m->headers;
		fillmesgwindow(-1, m);
		return 1;
	}
	if(iscmd(s, "Newpost")){
		m = newpost();
		winopenbody(m->w, OWRITE);
		Bprint(m->w->body, "%s\nsubject: \n\n", group);
		winclean(m->w);
		winselect(m->w, "$", 0);
		return 1;
	}
	if(m!=nil && !m->ispost && iscmd(s, "Reply")){
		replywindow(m);
		return 1;
	}
//	if(m!=nil && iscmd(s, "Replymail")){
//		fprint(2, "no replymail yet\n");
//		return 1;
//	}
	if(iscmd(s, "Post")){
		mesgpost(m);
		return 1;
	}
	return 0;
}