]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
read with wile loop config
authorBastian Dehn <hhaalo@arcor.de>
Sat, 2 Mar 2024 20:00:58 +0000 (21:00 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 2 Mar 2024 20:00:58 +0000 (21:00 +0100)
src/kds_s2000w_config.c

index 43237378a97b5388ab1316001cf6b7427f0a08a5..373f916dbd7bffc988b9519d797ccf764f9f3d0d 100644 (file)
@@ -166,34 +166,32 @@ void loadConfig(program_config* config, const char* config_stream)
 
        int stream_pos = 0;
 
-       get_line(config_stream, &line, &stream_pos);
-       get_key(&line, &value);
-       get_value(&line, &value);
-       trim_config_value(&value);
-
-       if (strcmp(value.key, "scanner_url") == 0) {
-               config->scanner_url = malloc(sizeof(char) * value.value_length);
-               memcpy(config->scanner_url, value.value, value.value_length);
-       }
-
-       free(line.line);
-       line.line = NULL;
-       line.length = 0;
-       free(value.key);
-       value.key = NULL;
-       value.key_length = 0;
-       free(value.value);
-       value.value = NULL;
-       value.value_length = 0;
-
-       get_line(config_stream, &line, &stream_pos);
-       get_key(&line, &value);
-       get_value(&line, &value);
-       trim_config_value(&value);
 
-       if (strcmp(value.key, "username") == 0) {
-               config->username = malloc(sizeof(char) * value.value_length);
-               memcpy(config->username, value.value, value.value_length);
+       while(strlen(config_stream) > stream_pos) {
+               free(line.line);
+               line.line = NULL;
+               line.length = 0;
+               free(value.key);
+               value.key = NULL;
+               value.key_length = 0;
+               free(value.value);
+               value.value = NULL;
+               value.value_length = 0;
+
+               get_line(config_stream, &line, &stream_pos);
+               get_key(&line, &value);
+               get_value(&line, &value);
+               trim_config_value(&value);
+
+               if (strcmp(value.key, "scanner_url") == 0) {
+                       config->scanner_url = malloc(sizeof(char) * value.value_length);
+                       memcpy(config->scanner_url, value.value, value.value_length);
+               }
+
+               if (strcmp(value.key, "username") == 0) {
+                       config->username = malloc(sizeof(char) * value.value_length);
+                       memcpy(config->username, value.value, value.value_length);
+               }
        }
 
        free(line.line);