diff options
| author | 2023-08-03 09:02:08 +0200 | |
|---|---|---|
| committer | 2023-08-03 09:02:08 +0200 | |
| commit | f5a3dbf8d652dbf87f9ff27b50d11f6364551a61 (patch) | |
| tree | a3c8fabb5baa25bde203a9cc8089134b8774d723 /utils.c | |
| parent | Backport from xs. (diff) | |
| download | snac2-f5a3dbf8d652dbf87f9ff27b50d11f6364551a61.tar.gz snac2-f5a3dbf8d652dbf87f9ff27b50d11f6364551a61.tar.xz snac2-f5a3dbf8d652dbf87f9ff27b50d11f6364551a61.zip | |
Use xs_json_dump_pp() wherever possible.
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 12 |
1 files changed, 4 insertions, 8 deletions
| @@ -194,8 +194,7 @@ int snac_init(const char *basedir) | |||
| 194 | return 1; | 194 | return 1; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | xs *j = xs_json_dumps_pp(srv_config, 4); | 197 | xs_json_dump_pp(srv_config, 4, f); |
| 198 | fwrite(j, strlen(j), 1, f); | ||
| 199 | fclose(f); | 198 | fclose(f); |
| 200 | 199 | ||
| 201 | printf("Done.\n"); | 200 | printf("Done.\n"); |
| @@ -276,8 +275,7 @@ int adduser(const char *uid) | |||
| 276 | return 1; | 275 | return 1; |
| 277 | } | 276 | } |
| 278 | else { | 277 | else { |
| 279 | xs *j = xs_json_dumps_pp(config, 4); | 278 | xs_json_dump_pp(config, 4, f); |
| 280 | fwrite(j, strlen(j), 1, f); | ||
| 281 | fclose(f); | 279 | fclose(f); |
| 282 | } | 280 | } |
| 283 | 281 | ||
| @@ -292,8 +290,7 @@ int adduser(const char *uid) | |||
| 292 | return 1; | 290 | return 1; |
| 293 | } | 291 | } |
| 294 | else { | 292 | else { |
| 295 | xs *j = xs_json_dumps_pp(key, 4); | 293 | xs_json_dump_pp(key, 4, f); |
| 296 | fwrite(j, strlen(j), 1, f); | ||
| 297 | fclose(f); | 294 | fclose(f); |
| 298 | } | 295 | } |
| 299 | 296 | ||
| @@ -319,8 +316,7 @@ int resetpwd(snac *snac) | |||
| 319 | snac->config = xs_dict_set(snac->config, "passwd", hashed_pwd); | 316 | snac->config = xs_dict_set(snac->config, "passwd", hashed_pwd); |
| 320 | 317 | ||
| 321 | if ((f = fopen(fn, "w")) != NULL) { | 318 | if ((f = fopen(fn, "w")) != NULL) { |
| 322 | xs *j = xs_json_dumps_pp(snac->config, 4); | 319 | xs_json_dump_pp(snac->config, 4, f); |
| 323 | fwrite(j, strlen(j), 1, f); | ||
| 324 | fclose(f); | 320 | fclose(f); |
| 325 | 321 | ||
| 326 | printf("New password for user %s is %s\n", snac->uid, clear_pwd); | 322 | printf("New password for user %s is %s\n", snac->uid, clear_pwd); |