예제 #1
0
void *Rast3d_open_cell_old_no_header(const char *name, const char *mapset)
{
    RASTER3D_Map *map;
    char xname[GNAME_MAX], xmapset[GMAPSET_MAX];

    Rast3d_init_defaults();

    if (!Rast3d_mask_open_old()) {
	Rast3d_error(_("Rast3d_open_cell_old_no_header: error in Rast3d_mask_open_old"));
	return (void *)NULL;
    }

    map = Rast3d_malloc(sizeof(RASTER3D_Map));
    if (map == NULL) {
	Rast3d_error(_("Rast3d_open_cell_old_no_header: error in Rast3d_malloc"));
	return (void *)NULL;
    }

    G_unqualified_name(name, mapset, xname, xmapset);

    map->fileName = G_store(xname);
    map->mapset = G_store(xmapset);

    map->data_fd = G_open_old_misc(RASTER3D_DIRECTORY, RASTER3D_CELL_ELEMENT, xname, xmapset);
    if (map->data_fd < 0) {
	Rast3d_error(_("Rast3d_open_cell_old_no_header: error in G_open_old"));
	return (void *)NULL;
    }

    Rast3d_range_init(map);
    Rast3d_mask_off(map);

    return map;
}
예제 #2
0
int main(int argc, char **argv)
{
    int i;

    G_gisinit(argv[0]);


    for (i = 0; i < MAXVIEWS; i++) {
	char buf[BUFSIZ];
	viewopts[i] = G_define_option();
	sprintf(buf, "view%d", i + 1);
	viewopts[i]->key = G_store(buf);
	viewopts[i]->type = TYPE_STRING;
	viewopts[i]->required = (i ? NO : YES);
	viewopts[i]->multiple = YES;
	viewopts[i]->gisprompt = "old,cell,Raster";;
	sprintf(buf, _("Raster file(s) for View%d"), i + 1);
	viewopts[i]->description = G_store(buf);
    }

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    parse_command(viewopts, vfiles, &numviews, &frames);

    return wxEntry(argc, argv);
}
예제 #3
0
파일: GP2.c 프로젝트: AsherBond/MondocosmOS
/*!
   \brief Set point set style for thematic mapping

   Updates also style for each geopoint.
   
   \param id point set id
   \param layer layer number for thematic mapping
   \param color icon color column name
   \param width icon line width column name
   \param size icon size column name
   \param symbol icon symbol column name
   \param colors pointer to Colors structure or NULL

   \return 1 on success
   \return -1 on error (point set not found)
 */
int GP_set_style_thematic(int id, int layer, const char* color, const char* width,
			  const char* size, const char* symbol, struct Colors *color_rules)
{
    geosite *gp;
    
    G_debug(4, "GP_set_style_thematic(id=%d, layer=%d, color=%s, width=%s, size=%s, symbol=%s)", id, layer,
	    color, width, size, symbol);

    if (NULL == (gp = gp_get_site(id))) {
	return -1;
    }

    if(!gp->tstyle)
	gp->tstyle = (gvstyle_thematic *)G_malloc(sizeof(gvstyle_thematic));
    G_zero(gp->tstyle, sizeof(gvstyle_thematic));
    
    gp->tstyle->active = 1;
    gp->tstyle->layer = layer;
    if (color)
	gp->tstyle->color_column = G_store(color);
    if (symbol)
	gp->tstyle->symbol_column = G_store(symbol);
    if (size)
	gp->tstyle->size_column = G_store(size);
    if (width)
	gp->tstyle->width_column = G_store(width);

    Gp_load_sites_thematic(gp, color_rules);

    return 1;
}
예제 #4
0
int cseg_read_cell(CSEG * cseg, char *map_name, char *mapset)
{
    GW_LARGE_INT row, nrows;
    int map_fd;
    CELL *buffer;

    cseg->name = NULL;
    cseg->mapset = NULL;

    map_fd = Rast_open_old(map_name, mapset);
    nrows = Rast_window_rows();
    buffer = Rast_allocate_c_buf();
    for (row = 0; row < nrows; row++) {
	Rast_get_c_row(map_fd, buffer, row);
	if (Segment_put_row(&(cseg->seg), buffer, row) < 0) {
	    G_free(buffer);
	    Rast_close(map_fd);
	    G_warning("%s(): unable to segment put row for [%s] in [%s]",
		    me, map_name, mapset);
	    return (-1);
	}
    }

    Rast_close(map_fd);
    G_free(buffer);

    cseg->name = G_store(map_name);
    cseg->mapset = G_store(mapset);

    return 0;
}
예제 #5
0
파일: field.c 프로젝트: caomw/grass
/*!
  \brief Get information about link to database.
  
  Variables are substituted by values, link is index to array of
  dblinks.

  \param Map pointer to Map_info structure
  \param link link id

  \return pointer to new field_info structure
 */
struct field_info *Vect_get_dblink(const struct Map_info *Map, int link)
{
    struct field_info *fi;

    G_debug(1, "Vect_get_dblink(): link = %d", link);

    if (link >= Map->dblnk->n_fields) {
	G_warning(_("Requested dblink %d, maximum link number %d"), link,
		  Map->dblnk->n_fields - 1);
	return NULL;
    }

    fi = (struct field_info *)G_malloc(sizeof(struct field_info));
    fi->number = Map->dblnk->field[link].number;

    if (Map->dblnk->field[link].name != NULL)
	fi->name = G_store(Map->dblnk->field[link].name);
    else
	fi->name = NULL;

    fi->table = G_store(Map->dblnk->field[link].table);
    fi->key = G_store(Map->dblnk->field[link].key);
    fi->database = Vect_subst_var(Map->dblnk->field[link].database, Map);
    fi->driver = G_store(Map->dblnk->field[link].driver);

    return fi;
}
예제 #6
0
int read_labels(char *name, char *mapset)
{
    char fullname[GNAME_MAX + 2 * GMAPSET_MAX + 4];
    char buf[1024];
    char *key, *data;

    sprintf(fullname, "%s in %s", name, mapset);

    if (labels.count >= MAXLABELS) {
	error(fullname, "", "no more label files allowed");
	return 0;
    }

    labels.name[labels.count] = G_store(name);
    labels.mapset[labels.count] = G_store(mapset);

    while (input(2, buf, help)) {
	if (!key_data(buf, &key, &data))
	    continue;

	if (KEY("font")) {
	    get_font(data);
	    labels.font[labels.count] = G_store(data);
	    continue;
	}
	error(key, "", "illegal request (labels)");
    }

    labels.count++;
    return 1;
}
예제 #7
0
파일: field.c 프로젝트: caomw/grass
/*!
  \brief Add new DB connection to dblinks structure
  
  \param[in,out] p pointer to existing dblinks structure
  \param number layer number (1 for OGR)
  \param name   layer name (layer for OGR) - if not given use table name
  \param table  table name (layer for OGR)
  \param key    key name
  \param db     database name (datasource for OGR)
  \param driver driver name (dbf, postgresql, ogr, ...)
  
  \return 0 on success
  \return -1 error
 */
int Vect_add_dblink(struct dblinks *p, int number, const char *name,
		    const char *table, const char *key, const char *db,
		    const char *driver)
{
    int ret;

    G_debug(3, "Field number <%d>, name <%s>", number, name);
    if (!name) {
	/* if name is not given, use table name */
	name = table;
    }
    ret = Vect_check_dblink(p, number, name);
    if (ret == 1) {
	G_warning(_("Layer number %d or name <%s> already exists"), number,
		  name);
	return -1;
    }

    if (p->n_fields == p->alloc_fields) {
	p->alloc_fields += 10;
	p->field = (struct field_info *)G_realloc((void *)p->field,
						  p->alloc_fields *
						  sizeof(struct field_info));
    }

    p->field[p->n_fields].number = number;

    if (name != NULL) {
	p->field[p->n_fields].name = G_store(name);
	/* replace all spaces with underscore, otherwise dbln can't be read */
	G_strchg(p->field[p->n_fields].name, ' ', '_');
    }
    else
	p->field[p->n_fields].name = NULL;

    if (table != NULL)
	p->field[p->n_fields].table = G_store(table);
    else
	p->field[p->n_fields].table = NULL;

    if (key != NULL)
	p->field[p->n_fields].key = G_store(key);
    else
	p->field[p->n_fields].key = NULL;

    if (db != NULL)
	p->field[p->n_fields].database = G_store(db);
    else
	p->field[p->n_fields].database = NULL;

    if (driver != NULL)
	p->field[p->n_fields].driver = G_store(driver);
    else
	p->field[p->n_fields].driver = NULL;

    p->n_fields++;

    return 0;
}
예제 #8
0
파일: main.c 프로젝트: rkrug/grass-ci
static int profile(int coords, const char *map, const char *nulls, char **line)
{
    double e1, n1, e2, n2;
    char buf[1024], profile[1024];
    const char *argv[7];
    int argc = 0;
    int n;
    int projection;

    projection = G_projection();

    argv[argc++] = "r.profile";

    if (coords)
	argv[argc++] = "-g";

    sprintf(buf, "input=%s", map);
    argv[argc++] = G_store(buf);

    argv[argc++] = "output=-";

    sprintf(buf, "null_value=%s", nulls);
    argv[argc++] = G_store(buf);

    strcpy(profile, "coordinates=");
    for (n = 0; line[n]; n += 4) {
	int err = parse_line("line", &line[n], &e1, &n1, &e2, &n2, projection);

	if (err) {
	    G_usage();
	    exit(EXIT_FAILURE);
	}

	if (n > 0)
	    strcat(profile, ",");
	G_format_easting(e1, buf, projection);
	strcat(profile, buf);

	G_format_northing(n1, buf, projection);
	strcat(profile, ",");
	strcat(profile, buf);

	G_format_easting(e2, buf, projection);
	strcat(profile, ",");
	strcat(profile, buf);

	G_format_northing(n2, buf, projection);
	strcat(profile, ",");
	strcat(profile, buf);
    }

    argv[argc++] = profile;

    argv[argc++] = NULL;

    G_verbose_message(_("End coordinate: %.15g, %.15g"), e2, n2);

    return G_vspawn_ex(argv[0], argv);
}
예제 #9
0
void parse_args(int argc, char** argv,
		char** input, char** field,
		int* history, int* columns, int *shell)
{
    int i;
    const char *answer;
    
    struct Option *input_opt, *field_opt;
    struct Flag *hist_flag, *col_flag, *shell_flag, *region_flag, *topo_flag;
    
    input_opt = G_define_standard_option(G_OPT_V_MAP);

    field_opt = G_define_standard_option(G_OPT_V_FIELD);
    
    hist_flag = G_define_flag();
    hist_flag->key = 'h';
    hist_flag->description = _("Print history instead of info and exit");
    hist_flag->guisection = _("Print");

    col_flag = G_define_flag();
    col_flag->key = 'c';
    col_flag->description =
	_("Print types/names of table columns for specified layer instead of info and exit");
    col_flag->guisection = _("Print");

    shell_flag = G_define_flag();
    shell_flag->key = 'g';
    shell_flag->description = _("Print basic info in shell script style");
    shell_flag->guisection = _("Print");

    region_flag = G_define_flag();
    region_flag->key = 'e';
    region_flag->description = _("Print also region info in shell script style");
    region_flag->guisection = _("Print");

    topo_flag = G_define_flag();
    topo_flag->key = 't';
    topo_flag->description = _("Print also topology info in shell script style");
    topo_flag->guisection = _("Print");

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    *input = G_store(input_opt->answer);
    *field = G_store(field_opt->answer);
    *history = hist_flag->answer ? TRUE : FALSE;
    *columns = col_flag->answer  ? TRUE : FALSE;
    i = 0;
    *shell = SHELL_NO;
    if (shell_flag->answer)
	*shell |= SHELL_BASIC;
    if (region_flag->answer)
	*shell |= SHELL_REGION;
    if (topo_flag->answer)
	*shell |= SHELL_TOPO;
}
예제 #10
0
char *Rast3d_get_window_params(void)
{
    if (windowParam == NULL)
	return NULL;
    if (windowParam->answer == NULL)
	return NULL;
    if (strcmp(windowParam->answer, RASTER3D_WINDOW_ELEMENT) == 0)
	return G_store(RASTER3D_WINDOW_ELEMENT);
    return G_store(windowParam->answer);
}
예제 #11
0
static int set_login(const char *driver, const char *database, const char *user,
                     const char *password, const char *host, const char *port,
                     int overwrite)
{
    int i, found;
    LOGIN login;

    G_debug(3, "db_set_login(): drv=[%s] db=[%s] usr=[%s] pwd=[%s] host=[%s] port=[%s]",
	    driver, database, user, password, host, port);

    init_login(&login);

    if (read_file(&login) == -1)
	return DB_FAILED;

    found = FALSE;
    for (i = 0; i < login.n; i++) {
	if (strcmp(login.data[i].driver, driver) == 0 &&
	    strcmp(login.data[i].database, database) == 0) {
	    if (user)
		login.data[i].user = G_store(user);
	    else
		login.data[i].user = G_store("");

	    if (password)
		login.data[i].password = G_store(password);
	    else
		login.data[i].password = G_store("");

	    found = TRUE;
	    break;
	}
    }

    if (found) {
        if (overwrite)
            G_warning(_("DB connection <%s/%s> already exists and will be overwritten"),
                      driver, database ? database : "");
        else
            G_fatal_error(_("DB connection <%s/%s> already exists. "
                            "Re-run '%s' with '--%s' flag to overwrite existing settings."),
                          driver, database ? database : "", G_program_name(), "overwrite");
    }
    
    if (!found)
	add_login(&login, driver, database, user, password, host, port, -1);
    else
        add_login(&login, driver, database, user, password, host, port, i);

    if (write_file(&login) == -1)
	return DB_FAILED;

    return DB_OK;
}
예제 #12
0
/** 
 * \brief Insert map information into tgisMapList
 *
 * This function alocates a tgisMap, fills it with the provided information
 * and adds it to the list.
 * In case allocation fails, G_fatal_error() will be invoked by the
 * allocation function.
 *
 * All arguments are deep copied to the new allocated tgisMap struct.
 *
 * \param list The tgisMapList pointer
 * \param name The name of the map
 * \param mapset The name of the mapset
 * \param ts A pointer to the timestamp of the map
 *
 * */
void tgis_map_list_insert(tgisMapList *list, char *name, char*mapset, struct TimeStamp *ts)
{
    tgisMap *map = G_calloc(1, sizeof(tgisMap));
    map->name = G_store(name);
    map->mapset = G_store(mapset);
    
    if(ts->count == 1)
        G_set_timestamp(&(map->ts), &(ts->dt[0]));
    if(ts->count == 2)
        G_set_timestamp_range(&(map->ts), &(ts->dt[0]), &(ts->dt[1]));
    
    tgis_map_list_add(list, map);
}
예제 #13
0
void G_read_datum_table(void)
{
    FILE *fd;
    char file[GPATH_MAX];
    char buf[1024];
    int line;

    if (G_is_initialized(&table.initialized))
	return;

    sprintf(file, "%s%s", G_gisbase(), DATUMTABLE);

    fd = fopen(file, "r");
    if (!fd) {
	G_warning(_("unable to open datum table file: %s"), file);
	G_initialize_done(&table.initialized);
	return;
    }

    for (line = 1; G_getl2(buf, sizeof(buf), fd); line++) {
	char name[100], descr[100], ellps[100];
	struct datum *t;

	G_strip(buf);
	if (*buf == '\0' || *buf == '#')
	    continue;

	if (table.count >= table.size) {
	    table.size += 50;
	    table.datums = G_realloc(table.datums, table.size * sizeof(struct datum));
	}

	t = &table.datums[table.count];

	if (sscanf(buf, "%s \"%99[^\"]\" %s dx=%lf dy=%lf dz=%lf",
		   name, descr, ellps, &t->dx, &t->dy, &t->dz) != 6) {
	    G_warning(_("error in datum table file, line %d"), line);
	    continue;
	}

	t->name = G_store(name);
	t->descr = G_store(descr);
	t->ellps = G_store(ellps);

	table.count++;
    }

    qsort(table.datums, table.count, sizeof(struct datum), compare_table_names);

    G_initialize_done(&table.initialized);
}
예제 #14
0
파일: datum.c 프로젝트: caomw/grass
struct datum_list *read_datum_table(void)
{
    FILE *fd;
    char file[GPATH_MAX];
    char buf[4096];
    int line;
    struct datum_list *current = NULL, *outputlist = NULL;
    int count = 0;

    sprintf(file, "%s%s", G_gisbase(), DATUMTABLE);

    fd = fopen(file, "r");
    if (!fd) {
	G_warning(_("Unable to open datum table file <%s>"), file);
	return NULL;
    }

    for (line = 1; G_getl2(buf, sizeof(buf), fd); line++) {
	char name[100], descr[1024], ellps[100];
	double dx, dy, dz;

	G_strip(buf);
	if (*buf == '\0' || *buf == '#')
	    continue;

	if (sscanf(buf, "%s \"%1023[^\"]\" %s dx=%lf dy=%lf dz=%lf",
		   name, descr, ellps, &dx, &dy, &dz) != 6) {
	    G_warning(_("Error in datum table file <%s>, line %d"), file,
		      line);
	    continue;
	}

	if (current == NULL)
	    current = outputlist = G_malloc(sizeof(struct datum_list));
	else
	    current = current->next = G_malloc(sizeof(struct datum_list));
	current->name = G_store(name);
	current->longname = G_store(descr);
	current->ellps = G_store(ellps);
	current->dx = dx;
	current->dy = dy;
	current->dz = dz;
	current->next = NULL;

	count++;
    }

    fclose(fd);

    return outputlist;
}
예제 #15
0
/*!
 * \brief Get user's home directory
 *
 * Returns a pointer to a string which is the full path name of the
 * user's home directory.
 *
 * \return pointer to string
 * \return NULL on error
 */
const char *G__home(void)
{
    static int initialized;
    static const char *home = 0;

    if (G_is_initialized(&initialized))
	return home;

#ifdef __MINGW32__
    {
	char buf[GPATH_MAX];

	/* TODO: we should probably check if the dir exists */
	home = getenv("USERPROFILE");

	if (!home) {
	    sprintf(buf, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));

	    if (strlen(buf) >= 0)
		home = G_store(buf);
	}

	if (!home)
	    home = getenv("HOME");
    }
#else
    home = getenv("HOME");
#endif
    G_initialize_done(&initialized);
    return home;
}
예제 #16
0
/* on error, returns -1, otherwise returns 0 */
struct dxf_file *dxf_open(char *file)
{
    struct dxf_file *dxf;

    dxf = (struct dxf_file *)G_malloc(sizeof(struct dxf_file));

    dxf->name = G_store(file);
    if (!(dxf->fp = fopen(file, "r")))
	return NULL;

    /* get the file size */
    G_fseek(dxf->fp, 0L, SEEK_END);
    dxf->size = G_ftell(dxf->fp);
    rewind(dxf->fp);

    dxf->pos = 0;

    if (dxf->size < 500000)
	dxf->percent = 10;
    else if (dxf->size < 800000)
	dxf->percent = 5;
    else
	dxf->percent = 2;

    /* initialize G_percent() */
    G_percent(0, 100, dxf->percent);

    return dxf;
}
예제 #17
0
void write_pgm(void)
{
    char *mask_name = G_store(png.file_name);
    FILE *output;
    int x, y;
    unsigned int *p;

    mask_name[strlen(mask_name) - 2] = 'g';

    output = fopen(mask_name, "wb");
    if (!output)
	G_fatal_error("PNG: couldn't open mask file %s", mask_name);

    G_free(mask_name);

    fprintf(output, "P5\n%d %d\n255\n", png.width, png.height);

    for (y = 0, p = png.grid; y < png.height; y++) {
	for (x = 0; x < png.width; x++, p++) {
	    unsigned int c = *p;
	    int r, g, b, a;

	    png_get_pixel(c, &r, &g, &b, &a);

	    fputc((unsigned char)(255 - a), output);
	}
    }

    fclose(output);
}
예제 #18
0
파일: main.c 프로젝트: imincik/pkg-grass
static void add_search_dir(const char *name)
{
    char envvar_name[256];
    char *fullname = NULL;

    if (sscanf(name, "${%255[^}]}", envvar_name) == 1) {
	char *envvar_value = getenv(envvar_name);

	/* N.B. If the envvar isn't set, directory is skipped completely */
	if (envvar_value)
	    G_asprintf(&fullname, "%s%s", envvar_value,
		       (name + strlen(envvar_name) + 3));
    }
    else
	fullname = G_store(name);

    if (fullname) {
	searchdirs = (char **)G_realloc(searchdirs,
					(numsearchdirs + 1) * sizeof(char *));
	searchdirs[numsearchdirs] = fullname;
	G_convert_dirseps_to_host(searchdirs[numsearchdirs]);
	numsearchdirs++;
    }

    return;
}
예제 #19
0
char *GPJ_grass_to_wkt(struct Key_Value *proj_info,
		       struct Key_Value *proj_units,
		       int esri_style, int prettify)
{
    OGRSpatialReferenceH hSRS;
    char *wkt, *local_wkt;

    hSRS = GPJ_grass_to_osr(proj_info, proj_units);

    if (hSRS == NULL)
	return NULL;

    if (esri_style)
	OSRMorphToESRI(hSRS);

    if (prettify)
	OSRExportToPrettyWkt(hSRS, &wkt, 0);
    else
	OSRExportToWkt(hSRS, &wkt);

    local_wkt = G_store(wkt);
    CPLFree(wkt);
    OSRDestroySpatialReference(hSRS);
    return local_wkt;
}
예제 #20
0
파일: datum.c 프로젝트: caomw/grass
int GPJ_get_default_datum_params_by_name(const char *name, char **params)
{
    struct gpj_datum_transform_list *list, *old;
    int count = 0;

    list = GPJ_get_datum_transform_by_name(name);

    if (list == NULL) {
	*params = NULL;
	return -1;
    }

    /* Take the first parameter set in the list as the default
     * (will normally be a 3-parameter transformation)        */
    *params = G_store(list->params);

    while (list != NULL) {
	count++;
	old = list;
	list = list->next;
	GPJ_free_datum_transform(old);
    }

    return count;

}
예제 #21
0
파일: header.c 프로젝트: caomw/grass
/*!
   \brief Set comment or other info string in map header

   \param Map pointer to Map_info structure
   \param str comment or other info string

   \return 0
 */
int Vect_set_comment(struct Map_info *Map, const char *str)
{
    G_free(Map->head.comment);
    Map->head.comment = G_store(str);
    
    return 0;
}
예제 #22
0
int font_init_charset(const char *str)
{
    if (charset)
	G_free(charset);
    charset = G_store(str);
    return 0;
}
예제 #23
0
파일: header.c 프로젝트: caomw/grass
/*!
   \brief Set organization string in map header

   \param Map pointer to Map_info structure
   \param str organization name

   \return 0
*/
int Vect_set_organization(struct Map_info *Map, const char *str)
{
    G_free(Map->head.organization);
    Map->head.organization = G_store(str);

    return 0;
}
예제 #24
0
/*!
 * \brief Read the first line of a file in cell_misc/
 *
 * Read the first line of data from a cell_misc/ meta-data file.
 *
 * \param element  metadata component filename
 * \param name
 * \param mapset
 * \param *str  string to be populated with data
 * \return dynamically-allocated string on success
 * \return NULL on error
 */
static char *misc_read_line(const char *elem,
			    const char *name, const char *mapset)
{
    char buff[GNAME_MAX];
    FILE *fp;

    buff[0] = '\0';

    if (G_find_file2_misc("cell_misc", elem, name, mapset) == NULL)
	return NULL;

    fp = G_fopen_old_misc("cell_misc", elem, name, mapset);
    if (!fp) {
	G_warning(_("Unable to read <%s> for raster map <%s@%s>"),
		  elem, name, mapset);
	return NULL;
    }
    if (G_getl2(buff, sizeof(buff) - 1, fp) == 0) {
	/* file is empty */
	*buff = '\0';
    }

    if (fclose(fp) != 0)
	G_fatal_error(_("Error closing <%s> metadata file for raster map <%s@%s>"),
		      elem, name, mapset);

    return *buff ? G_store(buff) : NULL;
}
예제 #25
0
파일: R_G_init.c 프로젝트: cran/GRASS
int G_set_cygwinstring( char *name) {
    cygwinstring = NULL;
    if (name && *name)
      cygwinstring = G_store(name);

    return 0;
}
예제 #26
0
파일: header.c 프로젝트: caomw/grass
/*!
   \brief Set map name in map header

   \param Map pointer to Map_info structure
   \param str map name to be set

   \return 0 
 */
int Vect_set_map_name(struct Map_info *Map, const char *str)
{
    G_free(Map->head.map_name);
    Map->head.map_name = G_store(str);
    
    return 0;
}
예제 #27
0
파일: date.c 프로젝트: rashadkm/grass_cmake
/*!
 * \brief Current date and time.
 *
 * Returns a pointer to a string which is the current date and
 * time. The format is the same as that produced by the UNIX
 * <tt>date</tt> command.
 *
 * \return pointer to a string holding date/time
 */
const char *G_date(void)
{
    static int initialized;
    static char *date;
    time_t clock;
    struct tm *local;
    char *tdate;
    char *d;

    if (G_is_initialized(&initialized))
	return date;

    time(&clock);

    local = localtime(&clock);
    tdate = asctime(local);
    for (d = tdate; *d; d++)
	if (*d == '\n')
	    *d = 0;

    date = G_store(tdate);

    G_initialize_done(&initialized);

    return date;
}
예제 #28
0
static void show_options(FILE *fp, int maxlen, const char *str)
{
    char *buff = G_store(str);
    char *p1, *p2;
    int totlen, len;

    fprintf(fp, _("  %*s   options: "), maxlen, " ");
    totlen = maxlen + 13;
    p1 = buff;
    while ((p2 = strchr(p1, ','))) {
	*p2 = '\0';
	len = strlen(p1) + 1;
	if ((len + totlen) > 76) {
	    totlen = maxlen + 13;
	    fprintf(fp, "\n %*s", maxlen + 13, " ");
	}
	fprintf(fp, "%s,", p1);
	totlen += len;
	p1 = p2 + 1;
    }
    len = strlen(p1);
    if ((len + totlen) > 76)
	fprintf(fp, "\n %*s", maxlen + 13, " ");
    fprintf(fp, "%s\n", p1);

    G_free(buff);
}
예제 #29
0
파일: main.c 프로젝트: caomw/grass
static void parse_command(struct Option **viewopts,
			  char *vfiles[MAXVIEWS][MAXIMAGES],
			  int *numviews, int *numframes)
{
    int i, j, k;

    *numviews = *numframes = 0;

    for (i = 0; i < MAXVIEWS; i++) {
	if (viewopts[i]->answers) {
	    int numi, wildnum;

	    (*numviews)++;

	    for (j = 0, numi = 0; viewopts[i]->answers[j]; j++) {
		if ((NULL != strchr(viewopts[i]->answers[j], '*')) ||
		    (NULL != strchr(viewopts[i]->answers[j], '?')) ||
		    (NULL != strchr(viewopts[i]->answers[j], '['))) {
		    char **wildfiles = gee_wildfiles(viewopts[i]->answers[j],
						     "rast", &wildnum);

		    for (k = 0; k < wildnum; k++)
			vfiles[i][numi++] = wildfiles[k];
		}
		else
		    vfiles[i][numi++] = G_store(viewopts[i]->answers[j]);
	    }

	    /* keep track of smallest number of frames */
	    *numframes =
		*numframes ? *numframes > numi ? numi : *numframes : numi;
	}
    }
}
예제 #30
0
파일: header.c 프로젝트: caomw/grass
/*!
   \brief Set date when the source map was originally produced in map header

   \param Map pointer to Map_info structure
   \param str date given as a string

   \return 0
 */
int Vect_set_map_date(struct Map_info *Map, const char *str)
{
    G_free(Map->head.source_date);
    Map->head.source_date = G_store(str);
    
    return 0;
}