// find an entry in the db; return offset of id or FAIL int findKey(char *id) { int start = STARTDB; while (start < ENDDB-4) { // find the next entry start = findoccupied(start); if (start == FAIL) return FAIL; // start points to EEPROM id - check for match with id if (eestrmatch(start, id)) return start; // no match - skip the id and its value and continue scanning start = findend(start); // scan past id start = findend(start); // and value } return FAIL; }
// list the strings in the avpdb void cmd_ls(void) { int start = STARTDB; for (;;) { // find the next entry start = findoccupied(start); if (start == FAIL) return; eeputs(start); msgp(M_defmacro); start = findend(start); eeputs(start); spb('"'); speol(); start = findend(start); } }
// find an empty space of a given size or eep int findhole(int size) { int starthole = STARTDB, endhole; for (;;) { if (starthole + size > ENDDB) break; // ain't gonna fit starthole = findunoccupied(starthole); // first byte of next hole, or if (starthole == FAIL) break; // outa holes endhole = findoccupied(starthole); // first byte or next block, or if (endhole == FAIL) endhole = ENDDB+1; // the first byte thou shall not touch // endhole is now on first char of next non-empty block, or one past ENDDB if ((endhole - starthole) >= size) return starthole; // success starthole = endhole; // find another hole } overflow(M_eeprom); return 0; // placate compiler }
// list the strings in the avpdb void cmd_ls(void) { int start = STARTDB; for (;;) { // find the next entry start = findoccupied(start); if (start == FAIL) return; msgp(M_function); spb(' '); eeputs(start); spb(' '); spb('{'); start = findend(start); eeputs(start); spb('}'); spb(';'); speol(); start = findend(start); } }