grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

login.c File Reference

DBMI Library (base) - login settings. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Include dependency graph for login.c:

Go to the source code of this file.

Classes

struct  DATA
 
struct  LOGIN
 

Functions

static const char * login_filename (void)
 
static void init_login (LOGIN *login)
 
static void add_login (LOGIN *login, const char *dr, const char *db, const char *usr, const char *pwd, const char *host, const char *port, int idx)
 
static int read_file (LOGIN *login)
 
static int write_file (LOGIN *login)
 
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 db_set_login (const char *driver, const char *database, const char *user, const char *password)
 Set login parameters for driver/database. More...
 
int db_set_login2 (const char *driver, const char *database, const char *user, const char *password, const char *host, const char *port, int overwrite)
 Set login parameters for driver/database. More...
 
static int get_login (const char *driver, const char *database, const char **user, const char **password, const char **host, const char **port)
 
int db_get_login (const char *driver, const char *database, const char **user, const char **password)
 Get login parameters for driver/database. More...
 
int db_get_login2 (const char *driver, const char *database, const char **user, const char **password, const char **host, const char **port)
 Get login parameters for driver/database. More...
 
int db_get_login_dump (FILE *fd)
 Print all connection settings to file. More...
 

Detailed Description

DBMI Library (base) - login settings.

(C) 1999-2015 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
Joel Jones (CERL/UIUC), Radim Blazek

Definition in file login.c.

Function Documentation

◆ add_login()

static void add_login ( LOGIN login,
const char *  dr,
const char *  db,
const char *  usr,
const char *  pwd,
const char *  host,
const char *  port,
int  idx 
)
static

◆ db_get_login()

int db_get_login ( const char *  driver,
const char *  database,
const char **  user,
const char **  password 
)

Get login parameters for driver/database.

If driver/database is not found, output arguments are set to NULL.

Deprecated:
Use db_set_login2() instead.
Todo:
: GRASS 8: to be replaced by db_set_login2().
Parameters
driverdriver name
databasedatabase name (can be NULL)
[out]username
[out]passwordstring
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 357 of file login.c.

References get_login(), and NULL.

◆ db_get_login2()

int db_get_login2 ( const char *  driver,
const char *  database,
const char **  user,
const char **  password,
const char **  host,
const char **  port 
)

Get login parameters for driver/database.

If driver/database is not found, output arguments are set to NULL.

Parameters
driverdriver name
databasedatabase name (can be NULL)
[out]username
[out]passwordstring
[out]hostname
[out]port
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 379 of file login.c.

References get_login().

Referenced by db_get_connection().

◆ db_get_login_dump()

int db_get_login_dump ( FILE *  fd)

Print all connection settings to file.

Parameters
fdfile where to print settings
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 394 of file login.c.

References LOGIN::data, DATA::database, DB_FAILED, DB_OK, DATA::driver, G_debug(), DATA::host, init_login(), LOGIN::n, DATA::password, DATA::port, read_file(), and DATA::user.

◆ db_set_login()

int db_set_login ( const char *  driver,
const char *  database,
const char *  user,
const char *  password 
)

Set login parameters for driver/database.

Deprecated:
Use db_set_login2() instead.
Todo:
: GRASS 8: to be replaced by db_set_login2().
Parameters
driverdriver name
databasedatabase name
useruser name
passwordpassword string
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 263 of file login.c.

References FALSE, NULL, and set_login().

◆ db_set_login2()

int db_set_login2 ( const char *  driver,
const char *  database,
const char *  user,
const char *  password,
const char *  host,
const char *  port,
int  overwrite 
)

Set login parameters for driver/database.

Parameters
driverdriver name
databasedatabase name
useruser name
passwordpassword string
hosthost name
port
overwriteTRUE to overwrite existing connections
Returns
DB_OK on success
DB_FAILED on failure

Definition at line 284 of file login.c.

References set_login().

◆ get_login()

static int get_login ( const char *  driver,
const char *  database,
const char **  user,
const char **  password,
const char **  host,
const char **  port 
)
static

◆ init_login()

static void init_login ( LOGIN login)
static

Definition at line 53 of file login.c.

References LOGIN::a, LOGIN::data, and LOGIN::n.

Referenced by db_get_login_dump(), get_login(), and set_login().

◆ login_filename()

static const char * login_filename ( void  )
static

Definition at line 42 of file login.c.

References db_malloc(), file, G_config_path(), GPATH_MAX, and HOST_DIRSEP.

Referenced by read_file(), and write_file().

◆ read_file()

static int read_file ( LOGIN login)
static

◆ set_login()

static int set_login ( const char *  driver,
const char *  database,
const char *  user,
const char *  password,
const char *  host,
const char *  port,
int  overwrite 
)
static

◆ write_file()

static int write_file ( LOGIN login)
static