Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

plugins: Make 'struct configdata' argument to the configfile helper const

So plugins can use const structures, possibly saving a little bit of RAM.

Change-Id: I15b0ef20e7554caf5f6d1c12f6ab109ddf3c0dbd

+12 -12
+10 -10
apps/plugins/lib/configfile.c
··· 42 42 #endif 43 43 } 44 44 45 - int configfile_save(const char *filename, struct configdata *cfg, 45 + int configfile_save(const char *filename, const struct configdata *cfg, 46 46 int num_items, int version) 47 47 { 48 48 int fd; ··· 56 56 57 57 /* pre-allocate 10 bytes for INT */ 58 58 rb->fdprintf(fd, "file version: %10d\n", version); 59 - 59 + 60 60 for(i = 0;i < num_items;i++) { 61 61 switch(cfg[i].type) { 62 62 case TYPE_INT: ··· 91 91 return 0; 92 92 } 93 93 94 - int configfile_load(const char *filename, struct configdata *cfg, 94 + int configfile_load(const char *filename, const struct configdata *cfg, 95 95 int num_items, int min_version) 96 96 { 97 97 int fd; ··· 118 118 return -1; 119 119 } 120 120 } 121 - 121 + 122 122 for(i = 0;i < num_items;i++) { 123 123 if(!rb->strcmp(cfg[i].name, name)) { 124 124 switch(cfg[i].type) { ··· 149 149 } 150 150 } 151 151 } 152 - 152 + 153 153 rb->close(fd); 154 154 return 0; 155 155 } ··· 190 190 int found = 0; 191 191 int line_len = 0; 192 192 int pos = 0; 193 - 193 + 194 194 /* open the current config file */ 195 195 get_cfg_filename(path, MAX_PATH, filename); 196 196 fd = rb->open(path, O_RDWR); 197 197 if(fd < 0) 198 198 return -1; 199 - 199 + 200 200 /* read in the current stored settings */ 201 201 while((line_len = rb->read_line(fd, buf, 256)) > 0) 202 202 { ··· 211 211 } 212 212 pos += line_len; 213 213 } 214 - 214 + 215 215 /* if (name/val) is a new entry just append to file */ 216 216 if (found == 0) 217 217 /* pre-allocate 10 bytes for INT */ 218 218 rb->fdprintf(fd, "%s: %10d\n", name, val); 219 - 219 + 220 220 rb->close(fd); 221 - 221 + 222 222 return found; 223 223 }
+2 -2
apps/plugins/lib/configfile.h
··· 45 45 /* configfile_save - Given configdata entries this function will 46 46 create a config file with these entries, destroying any 47 47 previous config file of the same name */ 48 - int configfile_save(const char *filename, struct configdata *cfg, 48 + int configfile_save(const char *filename, const struct configdata *cfg, 49 49 int num_items, int version); 50 50 51 - int configfile_load(const char *filename, struct configdata *cfg, 51 + int configfile_load(const char *filename, const struct configdata *cfg, 52 52 int num_items, int min_version); 53 53 54 54 /* configfile_get_value - Given a key name, this function will