comparison src/config.c @ 4:59bf702b2b21

*: stylistic changes
author Paper <mrpapersonic@gmail.com>
date Sun, 14 Aug 2022 13:17:32 -0400
parents 7abb5d8b20ea
children be4835547dd0
comparison
equal deleted inserted replaced
3:8df8af626dca 4:59bf702b2b21
11 #endif 11 #endif
12 #include <windows.h> 12 #include <windows.h>
13 #include <windowsx.h> 13 #include <windowsx.h>
14 #define MAX_LINE_LENGTH 128 14 #define MAX_LINE_LENGTH 128
15 15
16 extern struct config_t config; // from main 16 extern struct config config; // from main
17 17
18 static unsigned int crc32b(unsigned char *message) { 18 static unsigned int crc32b(unsigned char *message) {
19 int i, j; 19 int i, j;
20 unsigned int byte, crc, mask; 20 unsigned int byte, crc, mask;
21 21
31 i = i + 1; 31 i = i + 1;
32 } 32 }
33 return ~crc; 33 return ~crc;
34 } 34 }
35 35
36 int cfg_load(struct config_t* config) { 36 int cfg_load(struct config* config) {
37 char line[MAX_LINE_LENGTH] = {0}, 37 char line[MAX_LINE_LENGTH] = {0},
38 *path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk\\config.txt"); 38 *path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk\\config.txt");
39 FILE* config_fp; 39 FILE* config_fp;
40 config_fp = fopen(path, "r"); 40 config_fp = fopen(path, "r");
41 if (config_fp == NULL) { 41 if (config_fp == NULL) {
56 } 56 }
57 free(path); 57 free(path);
58 return 0; 58 return 0;
59 } 59 }
60 60
61 int cfg_save(struct config_t config) { 61 int cfg_save(struct config config) {
62 char* path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk"); 62 char* path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk");
63 FILE* config_fp; 63 FILE* config_fp;
64 assert(!dirtools_create_directory(path)); 64 assert(!dirtools_create_directory(path));
65 free(path); 65 free(path);
66 path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk\\config.txt"); 66 path = dirtools_concat_paths(getenv("APPDATA"), "Winamp\\Plugins\\wgsdk\\config.txt");