GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71806
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
strings.c File Reference

GIS Library - Find raster map. More...

#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <grass/gis.h>
Include dependency graph for strings.c:

Go to the source code of this file.

Macros

#define NULL   0
 

Functions

int G_strcasecmp (const char *x, const char *y)
 String compare ignoring case (upper or lower) More...
 
int G_strncasecmp (const char *x, const char *y, int n)
 String compare ignoring case (upper or lower) - limited number of characters. More...
 
char * G_store (const char *s)
 Copy string to allocated memory. More...
 
char * G_store_upper (const char *s)
 Copy string to allocated memory and convert copied string to upper case. More...
 
char * G_store_lower (const char *s)
 Copy string to allocated memory and convert copied string to lower case. More...
 
char * G_strchg (char *bug, char character, char new)
 Replace all occurrences of character in string bug with new. More...
 
char * G_str_replace (const char *buffer, const char *old_str, const char *new_str)
 Replace all occurrences of old_str in buffer with new_str. More...
 
void G_strip (char *buf)
 Removes all leading and trailing white space from string. More...
 
char * G_chop (char *line)
 Chop leading and trailing white spaces. More...
 
void G_str_to_upper (char *str)
 Convert string to upper case. More...
 
void G_str_to_lower (char *str)
 Convert string to lower case. More...
 
int G_str_to_sql (char *str)
 Make string SQL compliant. More...
 
void G_squeeze (char *line)
 Remove superfluous white space. More...
 
char * G_strcasestr (const char *str, const char *substr)
 Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lower) More...
 

Detailed Description

GIS Library - Find raster map.

GIS Library - string/chring movement functions.

(C) 1999-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL
Todo:
merge interesting functions from ../datetime/scan.c here

(C) 1999-2008, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Dave Gerdes (USACERL)
Michael Shapiro (USACERL)
Amit Parghi (USACERL)
Bernhard Reiter (Intevation GmbH, Germany) and many others

Definition in file strings.c.

Macro Definition Documentation

#define NULL   0

Definition at line 26 of file strings.c.

Function Documentation

char* G_chop ( char *  line)

Chop leading and trailing white spaces.

space, \f, \n, \r, \t, \v 

Modified copy of G_squeeze() by RB in March 2000.

Parameters
linebuffer to be worked on
Returns
pointer to string

Definition at line 286 of file strings.c.

References t.

Referenced by dig_read_frmt_ascii(), G_parser(), G_str_to_color(), get_key_data(), Rast_parse_color_rule(), read_coor(), S_read(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), and Vect_read_ascii().

void G_squeeze ( char *  line)

Remove superfluous white space.

Leading and trailing white space is removed from the string line and internal white space which is more than one character is reduced to a single space character. White space here means spaces, tabs, linefeeds, newlines, and formfeeds.

Parameters
[in,out]line
Returns
Pointer to line

Definition at line 399 of file strings.c.

References l, and t.

Referenced by Rast_get_sample_bilinear(), Rast_get_sample_cubic(), and Rast_get_sample_nearest().

char* G_store ( const char *  s)

Copy string to allocated memory.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated string

Definition at line 86 of file strings.c.

References NULL.

Referenced by cairo_read_ppm(), cairo_write_ppm(), COM_Set_encoding(), db_get_default_database_name(), db_get_default_driver_name(), db_get_default_group_name(), db_get_default_schema_name(), db_whoami(), dig_read_frmt_ascii(), font_get_encoding(), font_init_freetype(), G__home(), G__read_Cell_head(), G__wps_print_process_description(), G_add_keyword(), G_config_path(), G_database_datum_name(), G_database_ellipse_name(), G_date(), G_fully_qualified_name(), G_get_available_mapsets(), G_init_logging(), G_ls2(), G_myname(), G_option_to_separator(), G_parser(), G_putenv(), G_read_datum_table(), G_read_ellipsoid_table(), G_set_key_value(), G_set_program_name(), G_store_lower(), G_store_upper(), G_str_replace(), G_tempfile_pid(), G_whoami(), GP_get_sitename(), GP_load_site(), GP_set_style_thematic(), GPJ__get_datum_params(), GPJ__get_ellipsoid_params(), GPJ_get_datum_by_name(), GPJ_get_datum_transform_by_name(), GPJ_get_default_datum_params_by_name(), GPJ_get_ellipsoid_by_name(), GPJ_grass_to_osr(), GPJ_osr_to_grass(), gsds_newh(), GV_get_vectname(), GV_load_vector(), GV_set_style_thematic(), gvl_file_newh(), html_polygon(), I_iclass_init_statistics(), I_SetClassTitle(), I_SetSigTitle(), M__add_element(), M_read_list(), parse_fontcap_entry(), Rast3d_fill_header(), Rast3d_get_window_params(), Rast3d_init_defaults(), Rast3d_key_get_string(), Rast3d_open_cell_new(), Rast3d_open_cell_old_no_header(), Rast3d_set_unit(), Rast__open_null_write(), Rast__open_old(), Rast__read_history(), Rast_append_history(), Rast_create_gdal_link(), Rast_get_cell_title(), Rast_get_gdal_link(), Rast_mask_info(), Rast_set_cats_fmt(), Rast_set_cats_title(), Rast_set_d_cat(), Rast_set_history(), read_datum_table(), read_ellipsoid_table(), read_pgm(), Segment_open(), tgis_get_database_name(), tgis_get_default_database_name(), tgis_get_driver_name(), tgis_map_list_insert(), V1_open_new_pg(), V1_open_old_pg(), Vect__open_old(), Vect_add_dblink(), Vect_close(), Vect_default_field_info(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), Vect_get_dblink(), Vect_get_finfo_geometry_type(), Vect_get_finfo_layer_name(), Vect_get_finfo_topology_info(), Vect_get_proj_name(), Vect_maptype_info(), Vect_set_comment(), Vect_set_date(), Vect_set_map_date(), Vect_set_map_name(), Vect_set_organization(), Vect_set_person(), Vect_sfa_line_geometry_type(), Vect_subst_var(), Vect_write_ascii(), and write_pgm().

char* G_store_lower ( const char *  s)

Copy string to allocated memory and convert copied string to lower case.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated lower case string

Definition at line 140 of file strings.c.

References G_store(), and G_str_to_lower().

char* G_store_upper ( const char *  s)

Copy string to allocated memory and convert copied string to upper case.

This routine allocates enough memory to hold the string s, copies s to the allocated memory, and returns a pointer to the allocated memory.

If s is NULL then empty string is returned.

Parameters
sstring
Returns
pointer to newly allocated upper case string

Definition at line 116 of file strings.c.

References G_store(), and G_str_to_upper().

char* G_str_replace ( const char *  buffer,
const char *  old_str,
const char *  new_str 
)

Replace all occurrences of old_str in buffer with new_str.

Code example:

char *name;
name = G_str_replace ( inbuf, ".exe", "" );
...
G_free (name);
Parameters
bufferinput string buffer
old_strstring to be replaced
new_strnew string
Returns
the newly allocated string, input buffer is unchanged

Definition at line 188 of file strings.c.

References count, G_store(), N, and NULL.

Referenced by db_read_dbmscap(), Vect_get_finfo_geometry_type(), and Vect_subst_var().

void G_str_to_lower ( char *  str)

Convert string to lower case.

Parameters
[in,out]strpointer to string

Definition at line 336 of file strings.c.

Referenced by G_store_lower(), and Vect_get_finfo_geometry_type().

int G_str_to_sql ( char *  str)

Make string SQL compliant.

Parameters
[in,out]strpointer to string
Returns
number of changed characters

Definition at line 356 of file strings.c.

References count.

void G_str_to_upper ( char *  str)

Convert string to upper case.

Parameters
[in,out]strpointer to string

Definition at line 318 of file strings.c.

Referenced by G_store_upper().

int G_strcasecmp ( const char *  x,
const char *  y 
)
char* G_strcasestr ( const char *  str,
const char *  substr 
)

Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lower)

Parameters
strstring where to find sub-string
substrsub-string
Returns
a pointer to the first occurrence of sub-string
NULL if no occurrences are found

Definition at line 430 of file strings.c.

References G_strncasecmp(), and NULL.

char* G_strchg ( char *  bug,
char  character,
char  new 
)

Replace all occurrences of character in string bug with new.

Parameters
[in,out]bugbase string
charactercharacter to replace
newnew character
Returns
bug string

Definition at line 159 of file strings.c.

Referenced by Vect_add_dblink().

int G_strncasecmp ( const char *  x,
const char *  y,
int  n 
)

String compare ignoring case (upper or lower) - limited number of characters.

Returning a value that has the same sign as the difference between the first differing pair of characters.

Note: strcasecmp() is affected by the locale (LC_CTYPE), while G_strcasecmp() isn't.

Parameters
xfirst string to compare
ysecond string to compare
nnumber or characters to compare
Returns
0 the two strings are equal
-1, 1

Definition at line 68 of file strings.c.

Referenced by G_strcasestr().