示例#1
0
文件: editmsg.c 项目: wfp5p/elm
static void print_message_so_far(FILE *edit_fd, const SEND_HEADER *shdr)
{
	/** This prints out the message typed in so far.  We accomplish
	    this in a cheap manner - close the file, reopen it for reading,
	    stream it to the screen, then close the file, and reopen it
	    for appending.  Simple, but effective!

	    A nice enhancement would be for this to -> page <- the message
	    if it's sufficiently long.  Too much work for now, though.
	**/

	char buffer[SLEN];

	fflush(edit_fd);
	fseek(edit_fd, 0L, 0);

	NewLine();
	PutLine(-1, -1, "To: %s\r\n",		format_long(shdr->to, 4));
	PutLine(-1, -1, "Cc: %s\r\n",		format_long(shdr->cc, 4));
	PutLine(-1, -1, "Bcc: %s\r\n",		format_long(shdr->bcc, 5));
	PutLine(-1, -1, "Subject: %s\r\n",	shdr->subject);
	NewLine();

	while (fgets(buffer, SLEN, edit_fd) != NULL) {
	  PutLine(-1, -1, buffer);
	  NewLine();
	}

	PutLine(-1, -1, catgets(elm_msg_cat, ElmSet, ElmEditmsgPrintContinue,
	    "\n\r(Continue entering message.)\n\r"));
}
示例#2
0
static void
pat_list_nodes(patricia *node, FILE * fp)
{
  int n;
  char tmpbuf[100];
  char *bp = tmpbuf;

  if (!node)
    return;

  format_long(node->key, tmpbuf, &bp, 99, 2);
  *bp = '\0';

  fprintf(fp,
          "node%u [label=\"{ <key> key = 0b%s (%u) | bit = %d | { <b0> 0 | <b1> 1 } }\", ",
          (unsigned int) node->key, tmpbuf, (unsigned int) node->key,
          node->bit);
  if (node->links[0]->bit > node->bit && node->links[1]->bit > node->bit)
    fputs("fillcolor=1", fp);
  else if (node->links[0]->bit <= node->bit && node->links[1]->bit <= node->bit)
    fputs("fillcolor=3", fp);
  else
    fputs("fillcolor=2", fp);

  fputs("];\n", fp);

  for (n = 0; n < 2; n++) {
    if (node->links[n]->bit > node->bit)
      pat_list_nodes(node->links[n], fp);
  }
}