Esempio n. 1
0
File: prefs.c Progetto: vigna/ne
char *exists_gprefs_dir(void) {
	static char *gprefs_dir = NULL;

	/* If we have been already called, we already computed the name. We
		should free up the name and re-compute it (because the global dir may
		have changed). */

	if (gprefs_dir) {
		free(gprefs_dir);
		gprefs_dir = NULL;
	}

	const char *global_dir;
	if ((global_dir = get_global_dir()) && (gprefs_dir = malloc(strlen(global_dir) + 3 ))) {
		strcpy(gprefs_dir, global_dir);
		struct stat s;
		if (stat(gprefs_dir, &s)) {
			free(gprefs_dir);
			return gprefs_dir = NULL;
		}
		else if (!S_ISDIR(s.st_mode)) {
			free(gprefs_dir);
			return gprefs_dir = NULL;
		}
		return strcat(gprefs_dir, "/");
	}
	return NULL;
}
Esempio n. 2
0
File: ne.c Progetto: hagenkaye/ne
void about()
{
    clear_entire_screen();
    displaying_info = true;
    int i;
    for (i = 0; NO_WARRANTY_msg[i]; i++)
    {
        if (i == ne_lines - 1)
        {
            break;
        }
        move_cursor(i, 0);
        output_string(NO_WARRANTY_msg[i], false);
    }
    if (++i < ne_lines - 1)
    {
        move_cursor(i, 0);
        if (exists_gprefs_dir())
        {
            output_string("Global Directory: ", false);
            output_string(exists_gprefs_dir(), false);
        }
        else
        {
            output_string("Global directory \"", false);
            output_string(get_global_dir(), false);
            output_string("\" not found!", false);
        }
    }
    reset_window();
    print_message(ABOUT_MSG);
}
Esempio n. 3
0
File: ne.c Progetto: vigna/ne
void about(void) {
	set_attr(0);
	clear_entire_screen();
	displaying_info = true;
	int i;
	for(i = 0; NO_WARRANTY_msg[i]; i++) {
		if (i == ne_lines - 1) break;
		move_cursor(i, 0);
		output_string(NO_WARRANTY_msg[i], false);
	}
	reset_window();

	char t[256] = ABOUT_MSG " Global directory";
	char * const gprefs_dir = exists_gprefs_dir();
	if (gprefs_dir) strncat(strncat(t, ": ", sizeof t - 1), gprefs_dir, sizeof t - 1);
	else strncat(strncat(strncat(t, " ", sizeof t - 1), get_global_dir(), sizeof t - 1), " not found!", sizeof t - 1);
	print_message(t);
}