コード例 #1
0
ファイル: note.c プロジェクト: blanciq/bq-killer
int count_spool(CHAR_DATA *ch, NOTE_DATA *spool)
{
    int count = 0;
    NOTE_DATA *pnote;

    for (pnote = spool; pnote != NULL; pnote = pnote->next)
	if (!hide_note(ch,pnote))
	    count++;

    return count;
}
コード例 #2
0
ファイル: note.c プロジェクト: rezalas/riftshadow
int count_spool(CHAR_DATA *ch, int type)
{
    int count = 0;
    MYSQL_RES *res;
    MYSQL_ROW row;
    char query[MSL];
    sprintf(query,"SELECT * FROM notes WHERE type=%d",type);
    res		= one_query_res(query);
    while((row=mysql_fetch_row(res)))
    {
	if(!hide_note(ch,row))
		count++;
    }
    mysql_free_result(res);
    return count;
}
コード例 #3
0
ファイル: note.c プロジェクト: rezalas/riftshadow
void parse_note( CHAR_DATA *ch, char *argument, int type )
{
    BUFFER *buffer;
    char buf[MAX_STRING_LENGTH], query[MSL];
    char arg[MAX_INPUT_LENGTH];
    MYSQL_RES *res;
    MYSQL_ROW row;
    char *list_name;
    int vnum;
    int anum;

    switch(type)
    {
	default:
	    return;
        case NOTE_NOTE:
	    list_name = "notes";
            break;
        case NOTE_IDEA:
	    list_name = "ideas";
            break;
        case NOTE_PENALTY:
	    list_name = "penalties";
            break;
        case NOTE_NEWS:
	    list_name = "news";
            break;
        case NOTE_CHANGES:
	    list_name = "changes";
            break;
    }

    argument = one_argument( argument, arg );
    smash_tilde( argument );

    if ( arg[0] == '\0' || !str_prefix( arg, "read" ) )
    {
        bool fAll;

        if ( !str_cmp( argument, "all" ) )
        {
            fAll = TRUE;
            anum = 0;
        }

        else if ( argument[0] == '\0' || !str_prefix(argument, "next"))
        /* read next unread note */
        {
            vnum = 0;
	    sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	    res	= one_query_res(query);
            while((row=mysql_fetch_row(res)))
            {
                if (!hide_note(ch,row))
                {
                    sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
                        vnum, row[1], row[4], row[2], row[3]);
                    send_to_char( buf, ch );
                    page_to_char( row[5], ch );
                    update_read(ch,atol(row[6]),atoi(row[0]));
		    mysql_free_result(res);
                    return;
                }
		else if(is_note_to(ch,row[1],row[3]))
		    vnum++;
            }
	    sprintf(buf,"You have no unread %s.\n\r",list_name);
	    send_to_char(buf,ch);
	    mysql_free_result(res);
            return;
        }

        else if ( is_number( argument ) )
        {
            fAll = FALSE;
            anum = atoi( argument );
        }
        else
        {
            send_to_char( "Read which number?\n\r", ch );
            return;
        }

        vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
        {
            if (is_note_to(ch,row[1],row[3]) && (vnum++ == anum))
            {
                sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
                        anum, row[1], row[4], row[2], row[3]);
                send_to_char( buf, ch );
                page_to_char( row[5], ch );
		update_read(ch,atol(row[6]),atoi(row[0]));
		mysql_free_result(res);
                return;
            }
        }

	sprintf(buf,"There aren't that many %s.\n\r",list_name);
	send_to_char(buf,ch);
	mysql_free_result(res);
        return;
    }

    if ( !str_prefix( arg, "list" ) )
    {
	vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);

        while((row=mysql_fetch_row(res)))
	{
	    if (is_note_to(ch,row[1],row[3]))
	    {
		sprintf( buf, "[%3d%s] %s: %s\n\r",
		    vnum, hide_note(ch,row) ? " " : "N",
		    row[1], row[4]);
		send_to_char( buf, ch );
		vnum++;
	    }
	}
	if (!vnum)
	{
	    switch(type)
	    {
		case NOTE_NOTE:	
		    send_to_char("There are no notes for you.\n\r",ch);
		    break;
		case NOTE_IDEA:
		    send_to_char("There are no ideas for you.\n\r",ch);
		    break;
		case NOTE_PENALTY:
		    send_to_char("There are no penalties for you.\n\r",ch);
		    break;
		case NOTE_NEWS:
		    send_to_char("There is no news for you.\n\r",ch);
		    break;
		case NOTE_CHANGES:
		    send_to_char("There are no changes for you.\n\r",ch);
		    break;
	    }
	}
	mysql_free_result(res);
	return;
    }

    if ( !str_prefix( arg, "remove" ) )
    {
        if ( !is_number( argument ) )
            return send_to_char( "Note remove which number?\n\r", ch );


        anum = atoi( argument );
        vnum = 0;
	sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
	{
            if (!str_cmp(ch->true_name, row[1]) && vnum++ == anum )
            {
                sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]);
		one_query(query);
                send_to_char( "Ok.\n\r", ch );
		mysql_free_result(res);
                return;
            }
        }

	send_to_char("You must provide the number of a note you have written to remove.\n\r",ch);
	mysql_free_result(res);
        return;
    }

    if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 2)
    {
        if ( !is_number( argument ) )
            return send_to_char( "Note delete which number?\n\r", ch );

        anum = atoi( argument );
        vnum = 0;
        sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type);
	res	= one_query_res(query);
        while((row=mysql_fetch_row(res)))
	{
            if ( is_note_to( ch,row[1],row[3] ) && vnum++ == anum )
            {
                sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]);
		one_query(query);
		send_to_char("Ok.\n\r",ch);
		mysql_free_result(res);
		return;
            }
        }

 	sprintf(buf,"There aren't that many %s.\n\r",list_name);
	send_to_char(buf,ch);
	mysql_free_result(res);
        return;
    }

    /* below this point only certain people can edit notes */
    if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL))
    ||  (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR)))
    {
	sprintf(buf,"You aren't high enough level to write %s.",list_name);
	send_to_char(buf,ch);
	return;
    }

    if ( !str_cmp( arg, "+" ) )
    {
	note_attach( ch,type );
	if (ch->pnote->type != type)
	    return send_to_char("You already have a different note in progress.\n\r",ch);

	if (strlen(ch->pnote->text)+strlen(argument) >= 4096)
	    return send_to_char( "Note too long.\n\r", ch );

 	buffer = new_buf();

	add_buf(buffer,ch->pnote->text);
	add_buf(buffer,argument);
	add_buf(buffer,"\n\r");
	free_pstring( ch->pnote->text );
	ch->pnote->text = palloc_string( buf_string(buffer) );
	free_buf(buffer);
	send_to_char( "Ok.\n\r", ch );
	return;
    }

    if (!str_cmp(arg,"-"))
    {
 	int len;
	bool found = FALSE;

	note_attach(ch,type);
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0')
	    return send_to_char("No lines left to remove.\n\r",ch);

	strcpy(buf,ch->pnote->text);

	for (len = strlen(buf); len > 0; len--)
 	{
	    if (buf[len] == '\r')
	    {
		if (!found)  /* back it up */
		{
		    if (len > 0)
			len--;
		    found = TRUE;
		}
		else /* found the second one */
		{
		    buf[len + 1] = '\0';
		    free_pstring(ch->pnote->text);
		    ch->pnote->text = palloc_string(buf);
		    return;
		}
	    }
	}
	buf[0] = '\0';
	free_pstring(ch->pnote->text);
	ch->pnote->text = palloc_string(buf);
	return;
    }

    if ( !str_prefix( arg, "subject" ) )
    {
	note_attach( ch,type );
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	free_pstring( ch->pnote->subject );
	ch->pnote->subject = palloc_string( argument );
	send_to_char( "Ok.\n\r", ch );
	return;
    }

    if ( !str_prefix( arg, "to" ) )
    {
	note_attach( ch,type );
        if (ch->pnote->type != type)
            return send_to_char("You already have a different note in progress.\n\r",ch);

	if (is_name("all", argument)
	&& !IS_IMMORTAL(ch)
	&& !IS_HEROIMM(ch)
	&& !(ch->pcdata->induct == CABAL_LEADER))
		return	send_to_char("Sorry, you can't do that!\n\r",ch);
	if (is_number(argument) && !IS_IMMORTAL(ch))
		return send_to_char("You can't do that.\n\r",ch);	
	free_pstring( ch->pnote->to_list );
	ch->pnote->to_list = palloc_string( argument );
	send_to_char( "Ok.\n\r", ch );
	return;
	}

    if ( !str_prefix( arg, "clear" ) )
    {
	if ( ch->pnote != NULL )
	{
	    free_note(ch->pnote);
	    ch->pnote = NULL;
	}

	send_to_char( "Ok.\n\r", ch );
	return;
    }

    if ( !str_prefix( arg, "show" ) )
    {
	if ( ch->pnote == NULL )
	    return send_to_char( "You have no note in progress.\n\r", ch );

	if (ch->pnote->type != type)
	    return send_to_char("You aren't working on that kind of note.\n\r",ch);

	sprintf( buf, "%s: %s\n\rTo: %s\n\r",
	    ch->pnote->sender,
	    ch->pnote->subject,
	    ch->pnote->to_list
	    );
	send_to_char( buf, ch );
	send_to_char( ch->pnote->text, ch );
	return;
    }

    if ( !str_prefix( arg, "post" ) || !str_prefix(arg, "send"))
    {
	char *strtime;

	if ( ch->pnote == NULL )
	    return send_to_char( "You have no note in progress.\n\r", ch );

        if (ch->pnote->type != type)
            return send_to_char("You aren't working on that kind of note.\n\r",ch);

	if (!str_cmp(ch->pnote->to_list,""))
	    return send_to_char("You need to provide a recipient (name, all, or immortal).\n\r", ch);

	if (!str_cmp(ch->pnote->subject,""))
	    return send_to_char("You need to provide a subject.\n\r",ch);
	if (is_affected_prof(ch, "note_written") && !IS_IMMORTAL(ch))
	    return send_to_char("You have written a note too recently.\n\r",ch);
	ch->pnote->next			= NULL;
	strtime				= ctime( &current_time );
	strtime[strlen(strtime)-1]	= '\0';
	ch->pnote->date			= palloc_string( strtime );
	ch->pnote->date_stamp		= current_time;

	append_note(ch->pnote);
	ch->pnote = NULL;
	send_to_char("Note sent.\n\r",ch);
	add_prof_affect(ch, "note_written", 4, TRUE);
	return;
    }

    send_to_char( "You can't do that.\n\r", ch );
    return;
}
コード例 #4
0
void parse_note( CHAR_DATA *ch, char *argument, int type )
{
	char arg[MAX_INPUT_LENGTH];
	NOTE_DATA *pnote;
	NOTE_DATA **list;
	char *list_name;
	int vnum = 0;
	int anum = 0;

	if ( IS_NPC(ch) )
		return;

	switch(type)
	{
		default:
		return;
		case NOTE_NOTE:
		list = &note_list;
		list_name = "notes";
		break;
		case NOTE_IDEA:
		list = &idea_list;
		list_name = "ideas";
		break;
		case NOTE_PENALTY:
		list = &penalty_list;
		list_name = "penalties";
		break;
		case NOTE_NEWS:
		list = &news_list;
		list_name = "news";
		break;
		case NOTE_CHANGES:
		list = &changes_list;
		list_name = "changes";
		break;
	}

	argument = one_argument( argument, arg );
	smash_tilde( argument );

	if ( arg[0] == '\0' || !str_prefix( arg, "read" ) )
	{
		bool fAll;

		if ( !str_cmp( argument, "all" ) )
		{
			fAll = TRUE;
			anum = 0;
		}

		else if ( argument[0] == '\0' || !str_prefix(argument, "next"))
		/* read next unread note */
		{
			vnum = 0;
			for ( pnote = *list; pnote != NULL; pnote = pnote->next)
			{
				if (!hide_note(ch,pnote))
				{
					send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
						vnum,
						pnote->sender,
						pnote->subject,
						pnote->date,
						pnote->to_list), ch );
					page_to_char( pnote->text, ch );
					update_read(ch,pnote);
					return;
				}
				else if (is_note_to(ch,pnote))
					vnum++;
			}
			send_to_char( Format("You have no unread %s.\n\r",list_name),ch);
			return;
		}

		else if ( is_number( argument ) )
		{
			fAll = FALSE;
			anum = atoi( argument );
		}
		else
		{
			send_to_char( "Read which number?\n\r", ch );
			return;
		}

		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) )
			{
				send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
					vnum - 1,
					pnote->sender,
					pnote->subject,
					pnote->date,
					pnote->to_list), ch );
				page_to_char( pnote->text, ch );
				update_read(ch,pnote);
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.\n\r",list_name),ch);
		return;
	}

	if ( !str_prefix( arg, "list" ) )
	{
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) )
			{
				send_to_char( Format("[%3d%s] %s: %s\n\r",
					vnum, hide_note(ch,pnote) ? " " : "N", 
					pnote->sender, pnote->subject), ch );
				vnum++;
			}
		}
		if (!vnum)
		{
			switch(type)
			{
				case NOTE_NOTE:	
				send_to_char("There are no notes for you.\n\r",ch);
				break;
				case NOTE_IDEA:
				send_to_char("There are no ideas for you.\n\r",ch);
				break;
				case NOTE_PENALTY:
				send_to_char("There are no penalties for you.\n\r",ch);
				break;
				case NOTE_NEWS:
				send_to_char("There is no news for you.\n\r",ch);
				break;
				case NOTE_CHANGES:
				send_to_char("There are no changes for you.\n\r",ch);
				break;
			}
		}
		return;
	}

	if ( !str_prefix( arg, "remove" ) )
	{
		if ( !is_number( argument ) )
		{
			send_to_char( "Note remove which number?\n\r", ch );
			return;
		}

		anum = atoi( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && vnum++ == anum )
			{
				note_remove( ch, pnote, FALSE );
				send_to_char( "Ok.\n\r", ch );
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.",list_name),ch);
		return;
	}

	if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1)
	{
		if ( !is_number( argument ) )
		{
			send_to_char( "Note delete which number?\n\r", ch );
			return;
		}

		anum = atoi( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next )
		{
			if ( is_note_to( ch, pnote ) && vnum++ == anum )
			{
				note_remove( ch, pnote,TRUE );
				send_to_char( "Ok.\n\r", ch );
				return;
			}
		}

		send_to_char( Format("There aren't that many %s.",list_name),ch);
		return;
	}

	if (!str_prefix(arg,"catchup"))
	{
		switch(type)
		{
			case NOTE_NOTE:	
			ch->pcdata->last_note = current_time;
			break;
			case NOTE_IDEA:
			ch->pcdata->last_idea = current_time;
			break;
			case NOTE_PENALTY:
			ch->pcdata->last_penalty = current_time;
			break;
			case NOTE_NEWS:
			ch->pcdata->last_news = current_time;
			break;
			case NOTE_CHANGES:
			ch->pcdata->last_changes = current_time;
			break;
		}
		return;
	}

	/* below this point only certain people can edit notes */
	if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL))
		||  (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR)))
	{
		send_to_char( Format("You aren't high enough level to write %s.",list_name),ch);
		return;
	}

	if ( !str_cmp ( arg, "new" ) || !str_cmp ( arg, "write" ) ) {
		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			send_to_char ( "You already have a different note in progress.\n\r", ch );
			return;
		}
		ch->desc->connected = CON_NOTE_TO;
		send_to_char ( "Address this message to whom: (all, staff, <name>) ", ch );
		return;
	}

	send_to_char( "You can't do that.\n\r", ch );
	return;
}
コード例 #5
0
void parse_note ( Creature *ch, const char *argument, int type )
{
	BUFFER *buffer;
	char buf[MAX_STRING_LENGTH];
	char arg[MAX_INPUT_LENGTH];
	NOTE_DATA *pnote;
	NOTE_DATA **list;
	const char *list_name;
	int vnum;
	int anum;

	if ( IS_NPC ( ch ) )
	{ return; }

	switch ( type ) {
		default:
			return;
		case NOTE_NOTE:
			list = &note_list;
			list_name = "notes";
			break;
		case NOTE_IDEA:
			list = &idea_list;
			list_name = "ideas";
			break;
		case NOTE_PENALTY:
			list = &penalty_list;
			list_name = "penalties";
			break;
		case NOTE_NEWS:
			list = &news_list;
			list_name = "news";
			break;
		case NOTE_CHANGES:
			list = &changes_list;
			list_name = "changes";
			break;
	}

	argument = ChopC ( argument, arg );
	smash_tilde ( argument );

	if ( arg[0] == '\0' || !str_prefix ( arg, "read" ) ) {
		bool fAll;

		if ( SameString ( argument, "all" ) ) {
			fAll = TRUE;
			anum = 0;
		}

		else if ( argument[0] == '\0' || !str_prefix ( argument, "next" ) )
			/* read next unread note */
		{
			vnum = 0;
			for ( pnote = *list; pnote != NULL; pnote = pnote->next ) {
				if ( !hide_note ( ch, pnote ) ) {
					sprintf ( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
							  vnum,
							  pnote->sender,
							  pnote->subject,
							  pnote->date,
							  pnote->to_list );
					writeBuffer ( buf, ch );
					writePage ( pnote->text, ch );
					update_read ( ch, pnote );
					return;
				} else if ( is_note_to ( ch, pnote ) )
				{ vnum++; }
			}
			snprintf ( buf, sizeof ( buf ), "You have no unread %s.\n\r", list_name );
			writeBuffer ( buf, ch );
			return;
		}

		else if ( is_number ( argument ) ) {
			fAll = FALSE;
			anum = atoi ( argument );
		} else {
			writeBuffer ( "Read which number?\n\r", ch );
			return;
		}

		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next ) {
			if ( is_note_to ( ch, pnote ) && ( vnum++ == anum || fAll ) ) {
				sprintf ( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
						  vnum - 1,
						  pnote->sender,
						  pnote->subject,
						  pnote->date,
						  pnote->to_list
						);
				writeBuffer ( buf, ch );
				writePage ( pnote->text, ch );
				update_read ( ch, pnote );
				return;
			}
		}

		snprintf ( buf, sizeof ( buf ), "There aren't that many %s.\n\r", list_name );
		writeBuffer ( buf, ch );
		return;
	}

	if ( !str_prefix ( arg, "list" ) ) {
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next ) {
			if ( is_note_to ( ch, pnote ) ) {
				sprintf ( buf, "[%3d%s] %s: %s\n\r",
						  vnum, hide_note ( ch, pnote ) ? " " : "N",
						  pnote->sender, pnote->subject );
				writeBuffer ( buf, ch );
				vnum++;
			}
		}
		if ( !vnum ) {
			switch ( type ) {
				case NOTE_NOTE:
					writeBuffer ( "There are no notes for you.\n\r", ch );
					break;
				case NOTE_IDEA:
					writeBuffer ( "There are no ideas for you.\n\r", ch );
					break;
				case NOTE_PENALTY:
					writeBuffer ( "There are no penalties for you.\n\r", ch );
					break;
				case NOTE_NEWS:
					writeBuffer ( "There is no news for you.\n\r", ch );
					break;
				case NOTE_CHANGES:
					writeBuffer ( "There are no changes for you.\n\r", ch );
					break;
			}
		}
		return;
	}

	if ( !str_prefix ( arg, "remove" ) ) {
		if ( !is_number ( argument ) ) {
			writeBuffer ( "Note remove which number?\n\r", ch );
			return;
		}

		anum = atoi ( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next ) {
			if ( is_note_to ( ch, pnote ) && vnum++ == anum ) {
				note_remove ( ch, pnote, FALSE );
				writeBuffer ( "Ok.\n\r", ch );
				return;
			}
		}

		snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name );
		writeBuffer ( buf, ch );
		return;
	}

	if ( !str_prefix ( arg, "delete" ) && get_trust ( ch ) >= MAX_LEVEL - 1 ) {
		if ( !is_number ( argument ) ) {
			writeBuffer ( "Note delete which number?\n\r", ch );
			return;
		}

		anum = atoi ( argument );
		vnum = 0;
		for ( pnote = *list; pnote != NULL; pnote = pnote->next ) {
			if ( is_note_to ( ch, pnote ) && vnum++ == anum ) {
				note_remove ( ch, pnote, TRUE );
				writeBuffer ( "Ok.\n\r", ch );
				return;
			}
		}

		snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name );
		writeBuffer ( buf, ch );
		return;
	}

	if ( !str_prefix ( arg, "catchup" ) ) {
		switch ( type ) {
			case NOTE_NOTE:
				ch->pcdata->last_note = current_time;
				break;
			case NOTE_IDEA:
				ch->pcdata->last_idea = current_time;
				break;
			case NOTE_PENALTY:
				ch->pcdata->last_penalty = current_time;
				break;
			case NOTE_NEWS:
				ch->pcdata->last_news = current_time;
				break;
			case NOTE_CHANGES:
				ch->pcdata->last_changes = current_time;
				break;
		}
		return;
	}

	/* below this point only certain people can edit notes */
	if ( ( type == NOTE_NEWS && !IS_TRUSTED ( ch, ANGEL ) )
			||  ( type == NOTE_CHANGES && !IS_TRUSTED ( ch, CREATOR ) ) ) {
		snprintf ( buf, sizeof ( buf ), "You aren't high enough level to write %s.", list_name );
		writeBuffer ( buf, ch );
		return;
	}

	if ( SameString ( arg, "+" ) ) {
		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			writeBuffer (
				"You already have a different note in progress.\n\r", ch );
			return;
		}

		if ( strlen ( ch->pnote->text ) + strlen ( argument ) >= 4096 ) {
			writeBuffer ( "Note too long.\n\r", ch );
			return;
		}

		buffer = new_buf();

		add_buf ( buffer, ch->pnote->text );
		add_buf ( buffer, argument );
		add_buf ( buffer, "\n\r" );
		PURGE_DATA ( ch->pnote->text );
		ch->pnote->text = assign_string ( buf_string ( buffer ) );
		recycle_buf ( buffer );
		writeBuffer ( "Ok.\n\r", ch );
		return;
	}

	if ( SameString ( arg, "-" ) ) {
		int len;
		bool found = FALSE;

		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			writeBuffer (
				"You already have a different note in progress.\n\r", ch );
			return;
		}

		if ( ch->pnote->text == NULL || ch->pnote->text[0] == '\0' ) {
			writeBuffer ( "No lines left to remove.\n\r", ch );
			return;
		}

		strcpy ( buf, ch->pnote->text );

		for ( len = strlen ( buf ); len > 0; len-- ) {
			if ( buf[len] == '\r' ) {
				if ( !found ) { /* back it up */
					if ( len > 0 )
					{ len--; }
					found = TRUE;
				} else { /* found the second one */
					buf[len + 1] = '\0';
					PURGE_DATA ( ch->pnote->text );
					ch->pnote->text = assign_string ( buf );
					return;
				}
			}
		}
		buf[0] = '\0';
		PURGE_DATA ( ch->pnote->text );
		ch->pnote->text = assign_string ( buf );
		return;
	}

	if ( !str_prefix ( arg, "subject" ) ) {
		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			writeBuffer (
				"You already have a different note in progress.\n\r", ch );
			return;
		}

		PURGE_DATA ( ch->pnote->subject );
		ch->pnote->subject = assign_string ( argument );
		writeBuffer ( "Ok.\n\r", ch );
		return;
	}

	if ( !str_prefix ( arg, "to" ) ) {
		note_attach ( ch, type );
		if ( ch->pnote->type != type ) {
			writeBuffer (
				"You already have a different note in progress.\n\r", ch );
			return;
		}
		PURGE_DATA ( ch->pnote->to_list );
		ch->pnote->to_list = assign_string ( argument );
		writeBuffer ( "Ok.\n\r", ch );
		return;
	}

	if ( !str_prefix ( arg, "clear" ) ) {
		if ( ch->pnote != NULL ) {
			recycle_note ( ch->pnote );
			ch->pnote = NULL;
		}

		writeBuffer ( "Ok.\n\r", ch );
		return;
	}

	if ( !str_prefix ( arg, "show" ) ) {
		if ( ch->pnote == NULL ) {
			writeBuffer ( "You have no note in progress.\n\r", ch );
			return;
		}

		if ( ch->pnote->type != type ) {
			writeBuffer ( "You aren't working on that kind of note.\n\r", ch );
			return;
		}

		sprintf ( buf, "%s: %s\n\rTo: %s\n\r",
				  ch->pnote->sender,
				  ch->pnote->subject,
				  ch->pnote->to_list
				);
		writeBuffer ( buf, ch );
		writeBuffer ( ch->pnote->text, ch );
		return;
	}

	if ( !str_prefix ( arg, "post" ) || !str_prefix ( arg, "send" ) ) {
		char *strtime;

		if ( ch->pnote == NULL ) {
			writeBuffer ( "You have no note in progress.\n\r", ch );
			return;
		}

		if ( ch->pnote->type != type ) {
			writeBuffer ( "You aren't working on that kind of note.\n\r", ch );
			return;
		}

		if ( SameString ( ch->pnote->to_list, "" ) ) {
			writeBuffer (
				"You need to provide a recipient (name, all, or immortal).\n\r",
				ch );
			return;
		}

		if ( SameString ( ch->pnote->subject, "" ) ) {
			writeBuffer ( "You need to provide a subject.\n\r", ch );
			return;
		}

		ch->pnote->next			= NULL;
		strtime				= ctime ( &current_time );
		strtime[strlen ( strtime ) - 1]	= '\0';
		ch->pnote->date			= assign_string ( strtime );
		ch->pnote->date_stamp		= current_time;

		append_note ( ch->pnote );
		ch->pnote = NULL;
		return;
	}

	writeBuffer ( "You can't do that.\n\r", ch );
	return;
}