Beispiel #1
0
static const char *login_filename(void)
{
    static char *file;

    if (!file) {
	file = (char *)malloc(1000);
	sprintf(file, "%s/.grasslogin64", G_home());
    }
    return file;
}
Beispiel #2
0
/*!
 * \brief Get user's .grass/ config path directory
 *
 * Returns a pointer to a string which is the full path name of the
 * user's .grass/ config directory in their home directory.
 *
 * The path is not guaranteed to exist.
(should it be?  see possible TODO below)
 *
 * \return pointer to string
 * \return NULL on error
 */
const char *G_rc_path(void)
{
/* choose better name for fn? */
/* HB: making a complete bollocks of this, but to express the idea... */
    const char *rcpath = 0;

    sprintf(rcpath, "%s%c%s", G_home(), HOST_DIRSEP, RCDIR);

#ifdef POSSIBILITY
    /* create it if it doesn't exist */
#include <errno.h>
    int ret;
    ret = G_mkdir(rcpath);
    if (ret == -1 && errno != EEXIST)
	G_fatal_error(_("Failed to create directory [%s]"), rcpath);
#endif

    return G_store(rcpath);
}
Beispiel #3
0
static int askfile(void)
{
    char file[GNAME_MAX];

    while (1) {
	Curses_prompt_gets("Enter file to hold report: ", file);
	G_strip(file);
	if (*file == 0)
	    return -1;
	if (G_index(file, '/'))
	    strcpy(buf, file);
	else
	    sprintf(buf, "%s/%s", G_home(), file);
	if (access(buf, 0) != 0)
	    return 1;
	sprintf(buf, "** %s already exists. choose another file", file);
	Beep();
	Curses_write_window(PROMPT_WINDOW, 2, 1, buf);
    }

    return 0;
}