lima-1.0b5/
lima-1.0b5/driver/
lima-1.0b5/driver/ChangeLog.old/
lima-1.0b5/driver/Win32/
lima-1.0b5/driver/compat/
lima-1.0b5/driver/include/
lima-1.0b5/driver/testsuite/
lima-1.0b5/driver/testsuite/clone/
lima-1.0b5/driver/testsuite/command/
lima-1.0b5/driver/testsuite/data/
lima-1.0b5/driver/testsuite/etc/
lima-1.0b5/driver/testsuite/include/
lima-1.0b5/driver/testsuite/inherit/
lima-1.0b5/driver/testsuite/inherit/master/
lima-1.0b5/driver/testsuite/log/
lima-1.0b5/driver/testsuite/single/
lima-1.0b5/driver/testsuite/single/tests/compiler/
lima-1.0b5/driver/testsuite/single/tests/efuns/
lima-1.0b5/driver/testsuite/single/tests/operators/
lima-1.0b5/driver/testsuite/u/
lima-1.0b5/driver/tmp/
lima-1.0b5/etc/
lima-1.0b5/lib/WWW/help/
lima-1.0b5/lib/cmds/
lima-1.0b5/lib/cmds/create/
lima-1.0b5/lib/cmds/player/attic/
lima-1.0b5/lib/contrib/bboard/
lima-1.0b5/lib/contrib/boards/
lima-1.0b5/lib/contrib/marriage/
lima-1.0b5/lib/contrib/roommaker/
lima-1.0b5/lib/contrib/transient_effect/
lima-1.0b5/lib/daemons/channel/
lima-1.0b5/lib/daemons/imud/
lima-1.0b5/lib/data/
lima-1.0b5/lib/data/config/
lima-1.0b5/lib/data/links/
lima-1.0b5/lib/data/news/
lima-1.0b5/lib/data/players/
lima-1.0b5/lib/data/secure/
lima-1.0b5/lib/domains/
lima-1.0b5/lib/domains/std/2.4.5/maze1/
lima-1.0b5/lib/domains/std/2.4.5/npc/
lima-1.0b5/lib/domains/std/2.4.5/post_dir/
lima-1.0b5/lib/domains/std/2.4.5/sub/
lima-1.0b5/lib/domains/std/camera/
lima-1.0b5/lib/domains/std/config/
lima-1.0b5/lib/domains/std/cult/
lima-1.0b5/lib/domains/std/effects/
lima-1.0b5/lib/domains/std/misc/
lima-1.0b5/lib/domains/std/monsters/
lima-1.0b5/lib/domains/std/recorder/
lima-1.0b5/lib/domains/std/rooms/
lima-1.0b5/lib/domains/std/rooms/beach/
lima-1.0b5/lib/domains/std/rooms/labyrinth/
lima-1.0b5/lib/domains/std/school/
lima-1.0b5/lib/domains/std/school/O/
lima-1.0b5/lib/domains/std/spells/
lima-1.0b5/lib/domains/std/spells/stock-mage/
lima-1.0b5/lib/domains/std/spells/stock-priest/
lima-1.0b5/lib/help/
lima-1.0b5/lib/help/admin/
lima-1.0b5/lib/help/hints/General_Questions/
lima-1.0b5/lib/help/hints/Pirate_Quest/
lima-1.0b5/lib/help/player/
lima-1.0b5/lib/help/player/bin/
lima-1.0b5/lib/help/player/quests/
lima-1.0b5/lib/help/wizard/
lima-1.0b5/lib/help/wizard/coding/guilds/
lima-1.0b5/lib/help/wizard/coding/rooms/
lima-1.0b5/lib/help/wizard/lib/daemons/
lima-1.0b5/lib/help/wizard/lib/lfun/
lima-1.0b5/lib/help/wizard/lib/std/
lima-1.0b5/lib/help/wizard/mudos_doc/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/interactive/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/concepts/
lima-1.0b5/lib/help/wizard/mudos_doc/driver/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/arrays/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/buffers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/compile/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/filesystem/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/floats/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/functions/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/general/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mappings/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mixed/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/numbers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/constructs/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/types/
lima-1.0b5/lib/include/driver/
lima-1.0b5/lib/log/
lima-1.0b5/lib/obj/admtool/
lima-1.0b5/lib/obj/admtool/internal/
lima-1.0b5/lib/obj/admtool/mudinfo/
lima-1.0b5/lib/obj/admtool/secure/
lima-1.0b5/lib/obj/secure/
lima-1.0b5/lib/obj/secure/cmd/
lima-1.0b5/lib/obj/secure/mailers/
lima-1.0b5/lib/obj/secure/shell/
lima-1.0b5/lib/obj/secure/shell/classes/
lima-1.0b5/lib/obj/tasktool/
lima-1.0b5/lib/obj/tasktool/internal/
lima-1.0b5/lib/open/
lima-1.0b5/lib/secure/
lima-1.0b5/lib/secure/cgi/
lima-1.0b5/lib/secure/modules/
lima-1.0b5/lib/secure/simul_efun/
lima-1.0b5/lib/std/adversary/
lima-1.0b5/lib/std/adversary/advancement/
lima-1.0b5/lib/std/adversary/armor/
lima-1.0b5/lib/std/adversary/blows/
lima-1.0b5/lib/std/adversary/death/
lima-1.0b5/lib/std/adversary/formula/
lima-1.0b5/lib/std/adversary/health/
lima-1.0b5/lib/std/adversary/pulse/
lima-1.0b5/lib/std/adversary/wield/
lima-1.0b5/lib/std/classes/event_info/
lima-1.0b5/lib/std/container/
lima-1.0b5/lib/std/living/
lima-1.0b5/lib/std/modules/contrib/
lima-1.0b5/lib/std/patterns/
lima-1.0b5/lib/std/race/
lima-1.0b5/lib/std/race/restricted/
lima-1.0b5/lib/std/room/
lima-1.0b5/lib/tmp/
lima-1.0b5/lib/trans/
lima-1.0b5/lib/trans/admincmds/
lima-1.0b5/lib/trans/obj/
lima-1.0b5/lib/wiz/
/* Do not remove the headers from this file! see /USAGE for more info. */

/*
** reporter.c
**
** Generic reporting facility (for bugs, ideas, typos, etc.).
** Lifted from Rust's "bug" command.
**
** Created: 4-Sep-94  Deathblade
*/

#include <config.h>
#include <mudlib.h>
#include <edit.h>
#include <log.h>

#define DIVIDER "\
\n***********************************************************************\n"

inherit M_ACCESS;

/*
** For security reasons (since we write these using unguarded()), the
** file names should be "constants" rather than passed into us.  Same
** thing goes for posting to newsgroups.
**
** This does imply that the Reporter is limited by virtue of need to
** change this file, but that is a necessity if this will be writing
** to restricted directories.
*/
private nosave mapping log_files = ([
				     "Bug" : LOG_BUG,
				     "Typo" : LOG_TYPO,
				     "Idea" : LOG_IDEA,
				     "Todo" : LOG_TODO,
                                    "Question" : LOG_QUESTION,
                                    "Feedback" : LOG_FEEDBACK,
				     ]);
private nosave mapping news_groups = ([
				       "Bug" : BUG_NEWSGROUP,
				       "Typo" : TYPO_NEWSGROUP,
				       "Idea" : IDEA_NEWSGROUP,
				       "Todo" : TODO_NEWSGROUP,
                                     "Question" : QUESTION_NEWSGROUP,
                                       "Feedback" : FEEDBACK_NEWSGROUP,
				       ]);
int busy = 0;

void create() {
    set_privilege(1);
}

private nomask void issue_report(string type, string subject, string text)
{
    string where_am_i;
    object env;

    env = environment(this_body());
    where_am_i = (env ? file_name(env) : "<nowhere>");

    if ( subject )
    {
        text = sprintf( "%s\n", text);

	unguarded(1, (: NEWS_D->system_post($(news_groups[type]),
					    $(subject),
					    $(text)) :));
    }
    else
    {
	text = sprintf("%s: %s reports from %s on %s--\n\n%s" DIVIDER,
		       type,
		       this_body()->query_name(),
		       where_am_i,
		       ctime(time()),
		       text);

	LOG_D->log(log_files[type], text);
    }

    write("Thanks for the report!\n");
}

/* handle the completion of the report */
private nomask void done_ed(string type, string subject, string *lines)
{
    busy--;
    
    if ( !lines )
    {
	printf("%s entry aborted.\n", type);
	return;
    }

    issue_report(type, subject, implode(lines, "\n") + "\n");
}

/*
** begin_report()
**
** Entry point for a full text-entry bug report.  When the user completes
** their entry of the report, it will be handled appropriately.
*/
varargs void begin_report(string type, string subject)
{
    if ( !log_files[type] )
	error("Illegal report type.\n");

    printf("** %s report **\n", type);
    busy++;
    new(EDIT_OB, EDIT_TEXT, 0, (: done_ed, type, subject :));
}

/*
** short_report()
**
** The text has already been entered/derived/whatever.  This will just
** go straight ahead and issue the appropriate report.
*/
varargs void short_report(string type, string subject, string text)
{
    if ( !log_files[type] )
	error("Illegal report type.\n");

    issue_report(type, subject, text);
}

/*
** report_something()
**
** Do the right thing based on the report type, the input, and the
** config settings.
*/
void report_something(string type, string input)
{
    object env;
    string this_place;

#ifdef LOG_DONT_POST

    if( !input || input == "" )
	begin_report(type);
    else
	short_report(type, 0, input);

#else

    env = environment(this_body());
    this_place = " Report from: " + (env ? file_name(env):"nowhere") + "...";
    if ( !input || input == "" )
	begin_report(type, type + this_place);
    else
        short_report(type, type + this_place, input);

#endif
}

void clean_up() {
    if (!busy) destruct(this_object());
}