8 #include <grass/dbmi.h>
9 #include <grass/glocale.h>
25 static const char *login_filename(
void)
30 file = (
char *)malloc(1000);
31 sprintf(file,
"%s/.grasslogin64",
G_home());
48 if (login->
n == login->
a) {
51 (
DATA *) realloc((
void *)login->
data, login->
a *
sizeof(
DATA));
72 char buf[2001], dr[500], db[500], usr[500], pwd[500];
75 file = login_filename();
77 G_debug(3,
"DB login file = <%s>", file);
79 if (stat(file, &info) != 0) {
80 G_debug(3,
"login file does not exist");
84 fd = fopen(file,
"r");
88 while (
G_getl2(buf, 2000, fd)) {
91 usr[0] = pwd[0] =
'\0';
92 ret = sscanf(buf,
"%[^|]|%[^|]|%[^|]|%[^\n]", dr, db, usr, pwd);
94 G_debug(3,
"ret = %d : drv=[%s] db=[%s] usr=[%s] pwd=[%s]",
95 ret, dr, db, usr, pwd);
121 file = login_filename();
123 G_debug(3,
"DB login file = <%s>", file);
125 fd = fopen(file,
"w");
131 chmod(file, S_IRUSR | S_IWUSR);
133 for (i = 0; i < login->
n; i++) {
136 fprintf(fd,
"|%s", login->
data[i].
user);
156 const char *password)
161 G_debug(3,
"db_set_login(): drv=[%s] db=[%s] usr=[%s] pwd=[%s]",
162 driver, database, user, password);
170 for (i = 0; i < login.
n; i++) {
171 if (strcmp(login.
data[i].
driver, driver) == 0 &&
189 add_login(&login, driver, database, user, password);
205 const char **password)
210 G_debug(3,
"db_get_login(): drv=[%s] db=[%s]", driver, database);
220 for (i = 0; i < login.
n; i++) {
221 if (strcmp(login.
data[i].
driver, driver) == 0 &&