ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL read_environment(const char *file, char ***env) { int assigned; FILE *F; if ((F = fopen(file, "r")) == NULL) return 0; read_env_file(F, env, &assigned); fclose(F); return assigned; }
/*! \brief Open display driver Default display driver is Cairo, if not available PNG is used. \return 0 on success \return 1 no monitor defined */ int D_open_driver(void) { const char *p, *m; G_debug(1, "D_open_driver():"); p = getenv("GRASS_RENDER_IMMEDIATE"); m = G__getenv("MONITOR"); if (m && G_strncasecmp(m, "wx", 2) == 0) { /* wx monitors always use GRASS_RENDER_IMMEDIATE. */ p = NULL; /* use default display driver */ } else if (m) { char *env; const char *v; char *u_m; if (p) G_warning(_("%s variable defined, %s ignored"), "MONITOR", "GRASS_RENDER_IMMEDIATE"); /* GRASS variable names should be upper case. */ u_m = G_store_upper(m); env = NULL; G_asprintf(&env, "MONITOR_%s_MAPFILE", u_m); v = G__getenv(env); p = m; if (v) { if (G_strcasecmp(p, "ps") == 0) G_putenv("GRASS_PSFILE", v); else G_putenv("GRASS_PNGFILE", v); } G_asprintf(&env, "MONITOR_%s_ENVFILE", u_m); v = G__getenv(env); if (v) read_env_file(v); } const struct driver *drv = (p && G_strcasecmp(p, "PNG") == 0) ? PNG_Driver() : (p && G_strcasecmp(p, "PS") == 0) ? PS_Driver() : (p && G_strcasecmp(p, "HTML") == 0) ? HTML_Driver() : #ifdef USE_CAIRO (p && G_strcasecmp(p, "cairo") == 0) ? Cairo_Driver() : Cairo_Driver(); #else PNG_Driver(); #endif if (p && G_strcasecmp(drv->name, p) != 0) G_warning(_("Unknown display driver <%s>"), p); G_verbose_message(_("Using display driver <%s>..."), drv->name); LIB_init(drv); init(); if (!getenv("GRASS_RENDER_IMMEDIATE") && !m) return 1; return 0; }