mirror of
https://github.com/synthetos/g2.git
synced 2026-09-28 16:11:44 +08:00
Work on configuration breakup
This commit is contained in:
+19
-18
@@ -415,24 +415,25 @@ index_t nv_get_index(const char *group, const char *token)
|
||||
index_t index_max = nv_index_max();
|
||||
|
||||
for (i=0; i < index_max; i++) {
|
||||
if ((c = GET_TOKEN_BYTE(token[0])) != str[0]) { continue; } // 1st character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[1])) == NUL) { if (str[1] == NUL) return(i);} // one character match
|
||||
if (c != str[1]) continue; // 2nd character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[2])) == NUL) { if (str[2] == NUL) return(i);} // two character match
|
||||
if (c != str[2]) continue; // 3rd character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[3])) == NUL) { if (str[3] == NUL) return(i);} // three character match
|
||||
if (c != str[3]) continue; // 4th character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[4])) == NUL) { if (str[4] == NUL) return(i);} // four character match
|
||||
if (c != str[4]) continue; // 5th character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[5])) == NUL) { if (str[5] == NUL) return(i);} // four character match
|
||||
if (c != str[5]) continue; // 6th character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[6])) == NUL) { if (str[6] == NUL) return(i);} // four character match
|
||||
if (c != str[6]) continue; // 7th character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[7])) == NUL) { if (str[7] == NUL) return(i);} // four character match
|
||||
if (c != str[7]) continue; // 8th character mismatch
|
||||
if ((c = GET_TOKEN_BYTE(token[8])) == NUL) { if (str[8] == NUL) return(i);} // four character match
|
||||
if (c != str[8]) continue; // 9th character mismatch
|
||||
return (i); // five character match
|
||||
auto config = cfgArray[i];
|
||||
if ((c = config.token[0]) != str[0]) { continue; } // 1st character mismatch
|
||||
if ((c = config.token[1]) == NUL) { if (str[1] == NUL) return(i); } // one character match
|
||||
if (c != str[1]) continue; // 2nd character mismatch
|
||||
if ((c = config.token[2]) == NUL) { if (str[2] == NUL) return(i); } // two character match
|
||||
if (c != str[2]) continue; // 3rd character mismatch
|
||||
if ((c = config.token[3]) == NUL) { if (str[3] == NUL) return(i); } // three character match
|
||||
if (c != str[3]) continue; // 4th character mismatch
|
||||
if ((c = config.token[4]) == NUL) { if (str[4] == NUL) return(i); } // four character match
|
||||
if (c != str[4]) continue; // 5th character mismatch
|
||||
if ((c = config.token[5]) == NUL) { if (str[5] == NUL) return(i); } // four character match
|
||||
if (c != str[5]) continue; // 6th character mismatch
|
||||
if ((c = config.token[6]) == NUL) { if (str[6] == NUL) return(i); } // four character match
|
||||
if (c != str[6]) continue; // 7th character mismatch
|
||||
if ((c = config.token[7]) == NUL) { if (str[7] == NUL) return(i); } // four character match
|
||||
if (c != str[7]) continue; // 8th character mismatch
|
||||
if ((c = config.token[8]) == NUL) { if (str[8] == NUL) return(i); } // four character match
|
||||
if (c != str[8]) continue; // 9th character mismatch
|
||||
return (i); // five character match
|
||||
}
|
||||
return (NO_MATCH);
|
||||
}
|
||||
|
||||
+8
-1
@@ -333,7 +333,14 @@ typedef struct cfgItem {
|
||||
|
||||
extern nvStr_t nvStr;
|
||||
extern nvList_t nvl;
|
||||
extern const cfgItem_t cfgArray[];
|
||||
|
||||
class cfgArraySynthesizer {
|
||||
public:
|
||||
const cfgItem_t& operator[](std::size_t idx) const;
|
||||
};
|
||||
|
||||
extern cfgArraySynthesizer cfgArray;
|
||||
|
||||
|
||||
//#define nv_header nv.list
|
||||
#define nv_header (&nvl.list[0])
|
||||
|
||||
+310
-53
File diff suppressed because it is too large
Load Diff
@@ -351,7 +351,7 @@ stat_t write_persistent_values()
|
||||
DEBUG_PRINT("io_buffer populated with %i bytes total\n", br);
|
||||
|
||||
// update the values in the buffer from the changes indexes in the current range
|
||||
for (nv->index = cnt; nv->index < (cnt + step); nv->index++) {
|
||||
for (nv->index = cnt; nv->index < std::min(nv_index_max(), cnt + step); nv->index++) {
|
||||
|
||||
// Found an entry that needs to be written
|
||||
if (nv->index == 0 || cfgArray[nv->index].flags & F_PERSIST) {
|
||||
|
||||
Reference in New Issue
Block a user