<commit_before>/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2018  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <kotaka/paths/system.h>
#include <kotaka/paths/verb.h>
#include <kotaka/assert.h>
#include <status.h>

inherit LIB_VERB;
inherit "/lib/sort";

string *query_parse_methods()
{
	return ({ "raw" });
}

void main(object actor, mapping roles)
{
	mixed index;
	object pinfo;
	mixed val;
	mixed *arr;
	int sz;

	if (query_user()->query_class() < 2) {
		send_out("Only a wizard can do that.\n");
		return;
	}

	index = roles["raw"];

	if (sscanf(index, "%d", index)) {
		pinfo = OBJECTD->query_program_info(index);

		if (!pinfo) {
			send_out("Program not found\n");
			return;
		}
	} else {
		index = status(index, O_INDEX);

		if (index == nil) {
			send_out("No such program is in service\n");

			return;
		}

		pinfo = OBJECTD->query_program_info(index);

		if (!pinfo) {
			send_out("Program not registered\n");
			return;
		}
	}

	val = pinfo->query_clone_count();

	if (val) {
		send_out("Program #" + index + " (" + val + " clones)\n");
	} else {
		send_out("Program #" + index + "\n");
	}

	send_out("Path: " + pinfo->query_path() + "\n");

	arr = pinfo->query_inherits();

	if (sz = sizeof(arr)) {
		int i;

		qsort(arr, 0, sz);

		send_out("Inherits:\n");

		for (i = 0; i < sz; i++) {
			object libpinfo;

			libpinfo = OBJECTD->query_program_info(arr[i]);

			if (libpinfo) {
				string libpath;

				libpath = libpinfo->query_path();

				if (libpinfo->query_destructed()) {
					send_out("    " + libpath + " (destructed #" + arr[i] + ")\n");
				} else {
					send_out("    " + libpath + " (#" + arr[i] + ")\n");
				}
			} else {
				send_out("    (unregistered program #" + arr[i] + ")\n");
			}
		}

		send_out("\n");
	}

	arr = pinfo->query_includes();

	if (sz = sizeof(arr)) {
		int i;

		qsort(arr, 0, sz);

		send_out("Includes:\n");

		for (i = 0; i < sz; i++) {
			send_out("    " + arr[i] + "\n");
		}

		send_out("\n");
	}

	val = pinfo->query_constructor();

	if (val) {
		send_out("Constructor: " + val + "\n");
	}

	arr = pinfo->query_inherited_constructors();<commit_msg>Don't sort includes and inherits<commit_after>/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2018  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <kotaka/paths/system.h>
#include <kotaka/paths/verb.h>
#include <kotaka/assert.h>
#include <status.h>

inherit LIB_VERB;
inherit "/lib/sort";

string *query_parse_methods()
{
	return ({ "raw" });
}

void main(object actor, mapping roles)
{
	mixed index;
	object pinfo;
	mixed val;
	mixed *arr;
	int sz;

	if (query_user()->query_class() < 2) {
		send_out("Only a wizard can do that.\n");
		return;
	}

	index = roles["raw"];

	if (sscanf(index, "%d", index)) {
		pinfo = OBJECTD->query_program_info(index);

		if (!pinfo) {
			send_out("Program not found\n");
			return;
		}
	} else {
		index = status(index, O_INDEX);

		if (index == nil) {
			send_out("No such program is in service\n");

			return;
		}

		pinfo = OBJECTD->query_program_info(index);

		if (!pinfo) {
			send_out("Program not registered\n");
			return;
		}
	}

	val = pinfo->query_clone_count();

	if (val) {
		send_out("Program #" + index + " (" + val + " clones)\n");
	} else {
		send_out("Program #" + index + "\n");
	}

	send_out("Path: " + pinfo->query_path() + "\n");

	arr = pinfo->query_inherits();

	if (sz = sizeof(arr)) {
		int i;

		send_out("Inherits:\n");

		for (i = 0; i < sz; i++) {
			object libpinfo;

			libpinfo = OBJECTD->query_program_info(arr[i]);

			if (libpinfo) {
				string libpath;

				libpath = libpinfo->query_path();

				if (libpinfo->query_destructed()) {
					send_out("    " + libpath + " (destructed #" + arr[i] + ")\n");
				} else {
					send_out("    " + libpath + " (#" + arr[i] + ")\n");
				}
			} else {
				send_out("    (unregistered program #" + arr[i] + ")\n");
			}
		}

		send_out("\n");
	}

	arr = pinfo->query_includes();

	if (sz = sizeof(arr)) {
		int i;

		send_out("Includes:\n");

		for (i = 0; i < sz; i++) {
			send_out("    " + arr[i] + "\n");
		}

		send_out("\n");
	}

	val = pinfo->query_constructor();

	if (val) {
		send_out("Constructor: " + val + "\n");
	}

	arr = pinfo->query_inherited_constructors();
{'fraction_non_alphanumeric': 0.1628403630539242, 'fraction_numerical': 0.003203416978109984, 'mean_word_length': 3.197162061239731, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5626339', 'n_tokens_mistral': 2256, 'n_tokens_neox': 1992, 'n_words': 571}