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

GIS Library - Program basename routines. More...

#include <grass/gis.h>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
Include dependency graph for basename.c:

Go to the source code of this file.

Functions

char * G_basename (char *filename, const char *desired_ext)
 Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged. More...
 
size_t G_get_num_decimals (const char *str)
 Get number of decimals from a string. More...
 
char * G_double_to_basename_format (double number, size_t ndigits, size_t ndecimals)
 Convert a double to a string substituting the dot with underscore 12.3456 => '12_3456'. More...
 
char * G_get_basename_separator ()
 Return the environmental basename variable or the default value. More...
 
char * G_join_basename_strings (const char **strings, size_t len)
 join an array of strings using the basename separator More...
 
char * G_generate_basename (const char *basename, double number, size_t ndigits, size_t ndecimals)
 Generate the format string. More...
 

Detailed Description

GIS Library - Program basename routines.

(C) 2001-2014 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
GRASS GIS Development Team

Definition in file basename.c.

Function Documentation

char* G_basename ( char *  filename,
const char *  desired_ext 
)

Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged.

Checks if a filename matches a certain file extension (case insensitive) and if so, truncates the string to the base file name (cf. basename Unix command)

Parameters
filenamestring containing filename
desired_extstring containing extension to look for (case insensitive)
Returns
pointer to filename

Definition at line 38 of file basename.c.

References G_strcasecmp().

Referenced by G_parser(), and G_set_program_name().

char* G_double_to_basename_format ( double  number,
size_t  ndigits,
size_t  ndecimals 
)

Convert a double to a string substituting the dot with underscore 12.3456 => '12_3456'.

Parameters
numberthe double number that will be convert to string
ndigitsthe number of integer digits in the output string
ndecimalsthe number of decimals in the output string
Returns
a formatted string

Definition at line 79 of file basename.c.

References GNAME_MAX.

Referenced by G_generate_basename().

char* G_generate_basename ( const char *  basename,
double  number,
size_t  ndigits,
size_t  ndecimals 
)

Generate the format string.

Parameters
basenameString with the basename
digitsNumber of digits number
decimalsNumber of decimal number
fillerString used to fill, default is 0
Returns
Format string

Definition at line 168 of file basename.c.

References G_double_to_basename_format(), and G_get_basename_separator().

char* G_get_basename_separator ( )

Return the environmental basename variable or the default value.

return pointer to basename separator

Definition at line 112 of file basename.c.

References GBASENAME_SEP, getenv(), and NULL.

Referenced by G_generate_basename(), and G_join_basename_strings().

size_t G_get_num_decimals ( const char *  str)

Get number of decimals from a string.

Parameters
strString to analyse
Returns
number of decimals

Definition at line 58 of file basename.c.

References NULL.

char* G_join_basename_strings ( const char **  strings,
size_t  len 
)

join an array of strings using the basename separator

Parameters
stringsis an array of strings
lenis the length of the array
Returns
a joined string

Definition at line 130 of file basename.c.

References G_get_basename_separator().