bmsd/rdconfig.c

changeset 194
d202777ebae5
parent 0
033898178630
child 696
f4de55f587c1
equal deleted inserted replaced
193:3cbd81ea9391 194:d202777ebae5
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2017-2018 2 * Copyright (C) 2017-2019
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the bms (Brewery Management System) 6 * This file is part of the bms (Brewery Management System)
7 * 7 *
51 {(char *)"mysql_database", getstr, (char **)&Config.mysql_database}, 51 {(char *)"mysql_database", getstr, (char **)&Config.mysql_database},
52 {(char *)"mqtt_host", getstr, (char **)&Config.mqtt_host}, 52 {(char *)"mqtt_host", getstr, (char **)&Config.mqtt_host},
53 {(char *)"mqtt_port", getint, (char **)&Config.mqtt_port}, 53 {(char *)"mqtt_port", getint, (char **)&Config.mqtt_port},
54 {(char *)"mqtt_user", getstr, (char **)&Config.mqtt_user}, 54 {(char *)"mqtt_user", getstr, (char **)&Config.mqtt_user},
55 {(char *)"mqtt_pass", getstr, (char **)&Config.mqtt_pass}, 55 {(char *)"mqtt_pass", getstr, (char **)&Config.mqtt_pass},
56 {(char *)"web_root", getstr, (char **)&Config.web_root},
56 {NULL, NULL, NULL} 57 {NULL, NULL, NULL}
57 }; 58 };
58 59
59 60
60 61
92 free(Config.mqtt_user); 93 free(Config.mqtt_user);
93 Config.mqtt_user = NULL; 94 Config.mqtt_user = NULL;
94 if (Config.mqtt_pass) 95 if (Config.mqtt_pass)
95 free(Config.mqtt_pass); 96 free(Config.mqtt_pass);
96 Config.mqtt_pass = NULL; 97 Config.mqtt_pass = NULL;
98
99 if (Config.web_root)
100 free(Config.web_root);
101 Config.web_root = NULL;
97 } 102 }
98 103
99 104
100 105
101 int wrconfig(void) 106 int wrconfig(void)
148 fprintf(fp, "#mqtt_user <username>\n"); 153 fprintf(fp, "#mqtt_user <username>\n");
149 if (Config.mqtt_pass) 154 if (Config.mqtt_pass)
150 fprintf(fp, "mqtt_pass %s\n", Config.mqtt_pass); 155 fprintf(fp, "mqtt_pass %s\n", Config.mqtt_pass);
151 else 156 else
152 fprintf(fp, "#mqtt_pwd <passwd>\n"); 157 fprintf(fp, "#mqtt_pwd <passwd>\n");
153 158 fprintf(fp, "#\n");
159
160 if (Config.web_root)
161 fprintf(fp, "web_root %s\n", Config.web_root);
162 else
163 fprintf(fp, "#web_root </path/to/webroot>\n");
154 fprintf(fp, "#\n"); 164 fprintf(fp, "#\n");
155 fprintf(fp, "# End of generated configuration\n"); 165 fprintf(fp, "# End of generated configuration\n");
156 fclose(fp); 166 fclose(fp);
157 free(mypath); 167 free(mypath);
158 mypath = NULL; 168 mypath = NULL;

mercurial