Adjusted code for mxml modifications

SVN revision: 1284
This commit is contained in:
2005-03-27 19:57:23 +00:00
parent 7065552421
commit 9a617d6e46
+27 -20
View File
@@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
Revision 1.599 2005/03/27 19:57:23 ritt
Adjusted code for mxml modifications
Revision 1.598 2005/03/24 22:58:32 ritt
Create root node 'list'
@@ -10054,16 +10057,16 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user, BOOL activate)
if (new_user) {
node = mxml_find_node(lbs->pwd_xml_tree, "/list");
node = mxml_add_node(node, "user", NULL);
node = mxml_add_node(node, ELEMENT_NODE, "user", NULL);
mxml_add_node(node, "full_name", getparam("new_full_name"));
mxml_add_node(node, "name", getparam("new_user_name"));
mxml_add_node(node, "email", getparam("new_user_email"));
mxml_add_node(node, ELEMENT_NODE, "full_name", getparam("new_full_name"));
mxml_add_node(node, ELEMENT_NODE, "name", getparam("new_user_name"));
mxml_add_node(node, ELEMENT_NODE, "email", getparam("new_user_email"));
if (activate)
mxml_add_node(node, "password", getparam("encpwd"));
mxml_add_node(node, ELEMENT_NODE, "password", getparam("encpwd"));
else
mxml_add_node(node, "password", new_pwd);
mxml_add_node(node, ELEMENT_NODE, "password", new_pwd);
} else {
/* replace record */
@@ -10076,12 +10079,12 @@ int save_user_config(LOGBOOK * lbs, char *user, BOOL new_user, BOOL activate)
subnode = mxml_find_node(node, "email_notify");
if (subnode)
mxml_delete_node(subnode);
mxml_add_node(node, "email_notify", NULL);
mxml_add_node(node, ELEMENT_NODE, "email_notify", NULL);
subnode = mxml_find_node(node, "email_notify");
for (i = 0; lb_list[i].name[0]; i++) {
sprintf(str, "sub_lb%d", i);
if (getparam(str) && atoi(getparam(str)))
mxml_add_node(subnode, "logbook", lb_list[i].name);
mxml_add_node(subnode, ELEMENT_NODE, "logbook", lb_list[i].name);
}
if (get_password_file(lbs, file_name, sizeof(file_name)))
@@ -18515,9 +18518,9 @@ BOOL convert_password_file(char *file_name)
char name[256], password[256], full_name[256], email[256], email_notify[256];
int i, len, fh;
char *buf, *p;
PMXML_NODE root, node;
PMXML_NODE root, list, node;
fh = open(file_name, O_RDONLY | O_TEXT);
fh = open(file_name, O_RDONLY | O_BINARY);
if (fh < 0)
return FALSE;
len = lseek(fh, 0, SEEK_END);
@@ -18531,7 +18534,7 @@ BOOL convert_password_file(char *file_name)
/* create backup */
strlcpy(name, file_name, sizeof(name));
strlcat(name, "_bak", sizeof(name));
fh = open(name, O_WRONLY | O_TEXT | O_CREAT, 0644);
fh = open(name, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0644);
if (fh > 0) {
write(fh, buf, len);
close(fh);
@@ -18543,7 +18546,8 @@ BOOL convert_password_file(char *file_name)
while (*p && isspace(*p))
p++;
root = mxml_create_root_node("list");
root = mxml_create_root_node();
list = mxml_add_node(root, ELEMENT_NODE, "list", NULL);
while (*p) {
@@ -18581,20 +18585,23 @@ BOOL convert_password_file(char *file_name)
return FALSE;
}
for (i = 0; i < (int) sizeof(email_notify) - 1 && *p && *p != '\n'; i++)
for (i = 0; i < (int) sizeof(email_notify) - 1 && *p && *p != '\r' && *p != '\n'; i++)
email_notify[i] = *p++;
email_notify[i] = 0;
if (*p++ != '\n') {
if (*p && *p != '\n' && *p != '\r') {
free(buf);
return FALSE;
}
node = mxml_add_node(root, "user", NULL);
mxml_add_node(node, "name", name);
mxml_add_node(node, "password", password);
mxml_add_node(node, "full_name", full_name);
mxml_add_node(node, "email", email);
mxml_add_node(node, "email_notify", email_notify);
while (*p && (*p == '\r' || *p == '\n'))
p++;
node = mxml_add_node(list, ELEMENT_NODE, "user", NULL);
mxml_add_node(node, ELEMENT_NODE, "name", name);
mxml_add_node(node, ELEMENT_NODE, "password", password);
mxml_add_node(node, ELEMENT_NODE, "full_name", full_name);
mxml_add_node(node, ELEMENT_NODE, "email", email);
mxml_add_node(node, ELEMENT_NODE, "email_notify", email_notify);
}
while (*p && isspace(*p))