Skip to content

Commit

Permalink
lib/db: Remove deprecated implementation of db_set_login() and replac…
Browse files Browse the repository at this point in the history
…e it with that of db_set_login2() (#4308)

`db_set_login()` is deprecated in 7.8.0 release with da399c5. Change its function signature and implementation to match that of the currently preferred `db_set_login2()`. Technically, this is removing the old function and introducing a new one with the same name, but a different signature.

Modify `db_set_login2()` to internally call `db_set_login()` function call. In the next major version, `db_set_login2()` should be removed to have only one method to get login details for simplicity.

See also #4308.

---------

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
  • Loading branch information
ymdatta authored Oct 23, 2024
1 parent a05ed29 commit 930d59a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions db/db.login/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}

if (db_set_login2(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
if (db_set_login(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
G_fatal_error(_("Unable to set user/password"));
}

Expand Down
3 changes: 2 additions & 1 deletion include/grass/defs/dbmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ const char *db_whoami(void);
void db_zero(void *, int);
void db_zero_string(dbString *);
unsigned int db_sizeof_string(const dbString *);
int db_set_login(const char *, const char *, const char *, const char *);
int db_set_login(const char *, const char *, const char *, const char *,
const char *, const char *, int);
int db_set_login2(const char *, const char *, const char *, const char *,
const char *, const char *, int);
int db_get_login(const char *, const char *, const char **, const char **,
Expand Down
21 changes: 11 additions & 10 deletions lib/db/dbmi_base/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,23 @@ static int set_login(const char *driver, const char *database, const char *user,
/*!
\brief Set login parameters for driver/database
\deprecated Use db_set_login2() instead.
\todo: GRASS 8: to be replaced by db_set_login2().
\param driver driver name
\param database database name
\param user user name
\param password password string
\param host host name
\param port
\param overwrite TRUE to overwrite existing connections
\return DB_OK on success
\return DB_FAILED on failure
*/
int db_set_login(const char *driver, const char *database, const char *user,
const char *password)
int db_set_login2(const char *driver, const char *database, const char *user,
const char *password, const char *host, const char *port,
int overwrite)
{
return set_login(driver, database, user, password, NULL, NULL, FALSE);
return db_set_login(driver, database, user, password, host, port,
overwrite);
}

/*!
Expand All @@ -285,9 +286,9 @@ int db_set_login(const char *driver, const char *database, const char *user,
\return DB_OK on success
\return DB_FAILED on failure
*/
int db_set_login2(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, const char *host, const char *port,
int overwrite)
{
return set_login(driver, database, user, password, host, port, overwrite);
}
Expand Down

0 comments on commit 930d59a

Please sign in to comment.