Exemple #1
0
/*
 * help_topic:  Given a topic, we search the help directory, and try to
 * find the right file, if all is cool, and we can open it, or zcat it,
 * then we call help_prompt to get the actually displaying of the file
 * on the road.
 */
static	void	help_topic (char *path, char *name)
{
    char	*filename = (char *) 0;

    if (!name)
        return;

    /* what is the base name? */
    malloc_sprintf(&filename, "%s/%s", path, name);
    if (filename[strlen(filename)-1] == '/')
        chop(filename, 1);

    /* let uzfopen have all the fun */
    if ((help_fp = uzfopen(&filename, path, 1)))
    {
        /* Isnt this a heck of a lot better then the kludge you were using? */
        help_put_it(name, "*** Help on %s", name);
        help_prompt(name, NULL);
    }
    else
        help_put_it (name, "*** No help available on %s: Use ? for list of topics", name);

    new_free(&filename);
    return;
}
Exemple #2
0
int	open_file_for_read (const char *filename)
{
	char *dummy_filename = (char *) 0;
        struct epic_loadfile *elf;
        struct stat sb;

        File * fr;

	malloc_strcpy(&dummy_filename, filename);
	elf = uzfopen(&dummy_filename, ".", 1, &sb);
	new_free(&dummy_filename);

        if (!elf) {
                new_free(&elf);
                return -1;
        }

	if (sb.st_mode & 0111)
	{
		say("Cannot open %s -- executable file", filename);	
		return -1;
	}

	fr=new_file(elf);
	return fr->id;
}
Exemple #3
0
/*
 * set_translation:  Called when the TRANSLATION variable is SET.
 * Attempts to load a new translation table.
 */
void set_translation(Window *win, char *tablename, int unused)
{
	FILE	*table;
	unsigned char	temp_table[512];
	char	*filename = NULL, *s;
	int	inputs[8];
	int	j,
		c = 0;
	char	buffer[BIG_BUFFER_SIZE + 1];

	if (!tablename)
	{
		translation = 0;
		return;
	}
	for (s = tablename; *s; s++)
	{
		if (isspace((unsigned char)*s))
		{
			*s = '\0';
			break;
		}			
	}
	
	tablename = upper(tablename);

	/* Check for transparent mode; ISO-8859/1, Latin-1 */
	if (!strcmp("LATIN_1", tablename))
	{
		translation = 0;
		return;
	}

	/* Else try loading the translation table from disk. */
	malloc_strcpy(&filename, TRANSLATION_PATH "/");
	malloc_strcat(&filename, tablename);
	if ( !(table = uzfopen(&filename, ".", 0)) )
	{
		say("Cannot open character table definition \"%s\" !",
			tablename);
		set_string_var(TRANSLATION_VAR, NULL);
		new_free(&filename);
		return;
	}

	/* Any problems in the translation tables between hosts are
	 * almost certain to be caused here.
	 * many scanf implementations do not work as defined. In particular,
	 * scanf should ignore white space including new lines (many stop
	 * at the new line character, hence the fgets and sscanf workaround),
	 * many fail to read 0xab as a hexadecimal number (failing on the
	 * x) despite the 0x being defined as optionally existing on input,
	 * and others zero out all the output variables if there is trailing
	 * non white space in the format string which doesn't appear on the
	 * input. Overall, the standard I/O libraries have a tendancy not
	 * to be very standard.
	 */

	while (fgets(buffer, 80, table))
	{
		sscanf(buffer, "0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x",
		    inputs+0, inputs+1, inputs+2, inputs+3,
		    inputs+4, inputs+5, inputs+6, inputs+7);
		for (j = 0; j<8; j++)
			temp_table[c++] = (unsigned char) inputs[j];
	}
	fclose(table);
	new_free(&filename);
	if (c == 512)
	{
		for (c = 0; c <= 255; c++)
		{
			transToClient[c] = temp_table[c];
			transFromClient[c] = temp_table[c | 256];
		}
#if 0
		for (c = 0; c <= 255; c++)
			transToClient[c] = c;
#endif

		translation = 1;
	}
	else
	{
		say("Error loading translation table \"%s\" !", tablename);
		set_string_var(TRANSLATION_VAR, NULL);
	}
}