Example #1
0
void
do_news(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, NEWS_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, NEWS_FILE);
}
Example #2
0
void
do_man(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, MAN_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, MAN_FILE);
}
Example #3
0
void
do_help(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, HELP_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, HELP_FILE);
}
Example #4
0
void
do_helpfile(dbref player, const char *dir, const char *file, char *topic, char *segment)
{
    if (show_subfile(player, dir, topic, segment, 0))
	return;
    index_file(player, topic, file);
}
Example #5
0
void
do_info(dbref player, const char *topic, const char *seg)
{
	char *buf;
	int f;
	int cols;
	int buflen = 80;

#ifdef DIR_AVALIBLE
	DIR *df;
	struct dirent *dp;
#endif
#ifdef WIN32
	HANDLE  hFind;
	BOOL    bMore;
	WIN32_FIND_DATA finddata;
	char    *dirname;
	int dirnamelen = 0;
#endif

	if (*topic) {
		if (!show_subfile(player, INFO_DIR, topic, seg, TRUE)) {
			notify(player, NO_INFO_MSG);
		}
	} else {
#ifdef DIR_AVALIBLE
		buf = (char *) calloc(1, buflen);
		(void) strcpyn(buf, buflen, "    ");
		f = 0;
		cols = 0;
		if ((df = (DIR *) opendir(INFO_DIR))) {
			while ((dp = readdir(df))) {

				if (*(dp->d_name) != '.') {
					if (!f)
						notify(player, "Available information files are:");
					if ((cols++ > 2) || ((strlen(buf) + strlen(dp->d_name)) > 63)) {
						notify(player, buf);
						strcpyn(buf, buflen, "    ");
						cols = 0;
					}
					strcatn(buf, buflen, dp->d_name);
					strcatn(buf, buflen, " ");
					f = strlen(buf);
					while ((f % 20) != 4)
						buf[f++] = ' ';
					buf[f] = '\0';
				}
			}
			closedir(df);
		}
		if (f)
			notify(player, buf);
		else
			notify(player, "No information files are available.");
		free(buf);
#elif WIN32
		buf = (char *) calloc(1,buflen);
		(void) strcpyn(buf, buflen, "    ");
		f = 0;
		cols = 0;

		dirnamelen = strlen(INFO_DIR) + 4;
		dirname = (char *) malloc(dirnamelen);
		strcpyn(dirname, dirnamelen, INFO_DIR);
		strcatn(dirname, dirnamelen, "*.*");
		hFind = FindFirstFile(dirname,&finddata);
		bMore = (hFind != (HANDLE) -1);

		free(dirname);

		while (bMore) {
			if (!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
				if (!f)
					notify(player, "Available information files are:");
				if ((cols++ > 2) || ((strlen(buf) + strlen(finddata.cFileName)) > 63)) {
					notify(player,buf);
					(void) strcpyn(buf, buflen, "    ");
					cols = 0;
				}
			    strcatn(buf, buflen, finddata.cFileName);
			    strcatn(buf, buflen, " ");
				f = strlen(buf);
				while((f %20) != 4)
					buf[f++] = ' ';
				buf[f] = '\0';
			}
			bMore = FindNextFile(hFind, &finddata);
		}
		
		if (f)
			notify(player, buf);
		else
			notify(player, "There are no information files available.");

		free(buf);
#else							/* !DIR_AVALIBLE && !WIN32 */
		notify(player, "Index not available on this system.");
#endif							/* !DIR_AVALIBLE && !WIN32 */
	}
}