completed device info

This commit is contained in:
IonutParau 2025-07-29 17:39:38 +02:00
parent 9e33d5a1d2
commit 93206a536d
3 changed files with 16 additions and 2 deletions

View File

@ -81,7 +81,18 @@ nn_deviceInfo_t *nn_addDeviceInfo(nn_deviceInfoList_t *list, nn_address address,
return list->info + i;
}
void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *key);
void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *address) {
nn_size_t j = 0;
for(nn_size_t i = 0; i < list->len; i++) {
if(nn_strcmp(list->info[i].address, address) == 0) {
nn_deleteDeviceInfo(&list->ctx, &list->info[i]);
} else {
list->info[j] = list->info[i];
j++;
}
}
list->len = j;
}
nn_bool_t nn_registerDeviceKey(nn_deviceInfo_t *deviceInfo, const char *key, const char *value) {
if(deviceInfo->len == deviceInfo->capacity) return false;

View File

@ -820,6 +820,9 @@ int main(int argc, char **argv) {
nn_registerDeviceKey(theRamStick, NN_DEVICEINFO_KEY_PRODUCT, "RAM 1:5");
nn_registerDeviceKey(theRamStick, NN_DEVICEINFO_KEY_VENDOR, "NeoComputers Technologies L.L.C.");
nn_addDeviceInfo(list, "test", 8);
nn_removeDeviceInfo(list, "test");
nn_deviceInfo_t *theCPU = nn_addDeviceInfo(list, NULL, 8);
nn_registerDeviceKey(theCPU, NN_DEVICEINFO_KEY_CLASS, NN_DEVICEINFO_CLASS_CPU);
nn_registerDeviceKey(theCPU, NN_DEVICEINFO_KEY_DESCRIPTION, "Processor");

View File

@ -441,7 +441,7 @@ typedef struct nn_deviceInfo_t nn_deviceInfo_t;
nn_deviceInfoList_t *nn_newDeviceInfoList(nn_Context *ctx, nn_size_t preallocate);
void nn_deleteDeviceInfoList(nn_deviceInfoList_t *deviceInfoList);
nn_deviceInfo_t *nn_addDeviceInfo(nn_deviceInfoList_t *list, nn_address address, nn_size_t maxKeys);
void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *key);
void nn_removeDeviceInfo(nn_deviceInfoList_t *list, const char *address);
nn_bool_t nn_registerDeviceKey(nn_deviceInfo_t *deviceInfo, const char *key, const char *value);
nn_deviceInfo_t *nn_getDeviceInfoAt(nn_deviceInfoList_t *list, nn_size_t idx);
nn_size_t nn_getDeviceCount(nn_deviceInfoList_t *list);