/* PlanetCore passes information to the OS in the form of * a table of key=value strings, separated by newlines. * * The list is terminated by an empty string (i.e. two * consecutive newlines). * * To make it easier to parse, we first convert all the * newlines into null bytes.
*/
void planetcore_prepare_table(char *table)
{ do { if (*table == '\n')
*table = 0;
table++;
} while (*(table - 1) || *table != '\n');
*table = 0;
}
constchar *planetcore_get_key(constchar *table, constchar *key)
{ int keylen = strlen(key);
do { if (!strncmp(table, key, keylen) && table[keylen] == '=') return table + keylen + 1;
table += strlen(table) + 1;
} while (strlen(table) != 0);
return NULL;
}
int planetcore_get_decimal(constchar *table, constchar *key, u64 *val)
{ constchar *str = planetcore_get_key(table, key); if (!str) return 0;
*val = strtoull(str, NULL, 10); return 1;
}
int planetcore_get_hex(constchar *table, constchar *key, u64 *val)
{ constchar *str = planetcore_get_key(table, key); if (!str) return 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.