open-license-manager
2014-08-05 82d408374c8ece8f13b50b93ff24ab9633de14f0
src/library/pc-identifiers.c
@@ -22,12 +22,12 @@
   AdapterInfo *adapterInfos;
   result_adapterInfos = getAdapterInfos(NULL, &adapter_num);
   if (result_adapterInfos != OK) {
   if (result_adapterInfos != FUNC_RET_OK) {
      //call generate_disk_pc_id;
      return result_adapterInfos;
   }
   result_diskinfos = getDiskInfos(NULL, &disk_num);
   if (result_diskinfos == OK) {
   if (result_diskinfos == FUNC_RET_OK) {
      required_id_size = disk_num * adapter_num;
   } else {
      required_id_size = disk_num;
@@ -35,9 +35,9 @@
   int defined_identifiers = *num_identifiers;
   *num_identifiers = required_id_size;
   if (identifiers == NULL) {
      return OK;
      return FUNC_RET_OK;
   } else if (required_id_size > defined_identifiers) {
      return BUFFER_TOO_SMALL;
      return FUNC_RET_BUFFER_TOO_SMALL;
   }
   diskInfos = (DiskInfo*) malloc(disk_num * sizeof(DiskInfo));
   result_diskinfos = getDiskInfos(diskInfos, &disk_num);
@@ -54,7 +54,7 @@
   free(diskInfos);
   free(adapterInfos);
   return OK;
   return FUNC_RET_OK;
}
static FUNCTION_RETURN generate_ethernet_pc_id(PcIdentifier * identifiers,
@@ -65,16 +65,16 @@
   AdapterInfo *adapterInfos;
   result_adapterInfos = getAdapterInfos(NULL, &adapters);
   if (result_adapterInfos != OK) {
   if (result_adapterInfos != FUNC_RET_OK) {
      return result_adapterInfos;
   }
   int defined_adapters = *num_identifiers;
   *num_identifiers = adapters;
   if (identifiers == NULL) {
      return OK;
      return FUNC_RET_OK;
   } else if (adapters > defined_adapters) {
      return BUFFER_TOO_SMALL;
      return FUNC_RET_BUFFER_TOO_SMALL;
   }
   adapterInfos = (AdapterInfo*) malloc(adapters * sizeof(AdapterInfo));
@@ -94,7 +94,7 @@
         }
   }
   free(adapterInfos);
   return OK;
   return FUNC_RET_OK;
}
static FUNCTION_RETURN generate_disk_pc_id(PcIdentifier * identifiers,
@@ -106,13 +106,13 @@
   DiskInfo * diskInfos;
   result_diskinfos = getDiskInfos(NULL, &disk_num);
   if (result_diskinfos != OK) {
   if (result_diskinfos != FUNC_RET_OK) {
      return result_diskinfos;
   }
   diskInfos = (DiskInfo*) malloc(disk_num * sizeof(DiskInfo));
   //memset(diskInfos,0,disk_num * sizeof(DiskInfo));
   result_diskinfos = getDiskInfos(diskInfos, &disk_num);
   if (result_diskinfos != OK) {
   if (result_diskinfos != FUNC_RET_OK) {
      free(diskInfos);
      return result_diskinfos;
   }
@@ -125,10 +125,10 @@
   *num_identifiers = available_disk_info;
   if (identifiers == NULL) {
      free(diskInfos);
      return OK;
      return FUNC_RET_OK;
   } else if (available_disk_info > defined_identifiers) {
      free(diskInfos);
      return BUFFER_TOO_SMALL;
      return FUNC_RET_BUFFER_TOO_SMALL;
   }
   j=0;
@@ -147,7 +147,7 @@
      }
   }
   free(diskInfos);
   return OK;
   return FUNC_RET_OK;
}
/**
@@ -188,10 +188,10 @@
      result = generate_disk_pc_id(identifiers, array_size, true);
      break;
   default:
      return ERROR;
      return FUNC_RET_ERROR;
   }
   if (result == OK && identifiers != NULL) {
   if (result == FUNC_RET_OK && identifiers != NULL) {
      strategy_num = strategy << 5;
      for (i = 0; i < *array_size; i++) {
         //encode strategy in the first three bits of the pc_identifier
@@ -243,17 +243,17 @@
   char* b64_data = base64(concat_identifiers, concatIdentifiersSize,
         &b64_size);
   if (b64_size > sizeof(PcSignature)) {
      return BUFFER_TOO_SMALL;
      return FUNC_RET_BUFFER_TOO_SMALL;
   }
   sprintf(pc_identifier_out, "%.4s-%.4s-%.4s-%.4s", &b64_data[0],
         &b64_data[4], &b64_data[8], &b64_data[12]);
//free(concat_identifiers);
   free(b64_data);
   return OK;
   return FUNC_RET_OK;
}
FUNCTION_RETURN parity_check_id(PcSignature pc_identifier) {
   return OK;
   return FUNC_RET_OK;
}
FUNCTION_RETURN generate_user_pc_signature(PcSignature identifier_out,
@@ -262,17 +262,17 @@
   PcIdentifier* identifiers;
   unsigned int req_buffer_size = 0;
   result = generate_pc_id(NULL, &req_buffer_size, strategy);
   if (result != OK) {
   if (result != FUNC_RET_OK) {
      return result;
   }
   if (req_buffer_size == 0) {
      return ERROR;
      return FUNC_RET_ERROR;
   }
   req_buffer_size = req_buffer_size < 2 ? 2 : req_buffer_size;
   identifiers = (PcIdentifier *) malloc(
         sizeof(PcIdentifier) * req_buffer_size);
   result = generate_pc_id(identifiers, &req_buffer_size, strategy);
   if (result != OK) {
   if (result != FUNC_RET_OK) {
      free(identifiers);
      return result;
   }
@@ -303,13 +303,13 @@
         &base64ids[8], &base64ids[12]);
   concat_identifiers = unbase64(base64ids, 16, &identifiers_size);
   if (identifiers_size > sizeof(PcIdentifier) * 2) {
      return BUFFER_TOO_SMALL;
      return FUNC_RET_BUFFER_TOO_SMALL;
   }
   memcpy(identifier1_out, concat_identifiers, sizeof(PcIdentifier));
   memcpy(identifier2_out, concat_identifiers + sizeof(PcIdentifier),
         sizeof(PcIdentifier));
   free(concat_identifiers);
   return OK;
   return FUNC_RET_OK;
}
static IDENTIFICATION_STRATEGY strategy_from_pc_id(PcIdentifier identifier) {
@@ -328,7 +328,7 @@
   printf("Comparing pc identifiers: \n");
#endif
   result = decode_pc_id(user_identifiers[0], user_identifiers[1], str_code);
   if (result != OK) {
   if (result != FUNC_RET_OK) {
      return result;
   }
   previous_strategy_id = STRATEGY_UNKNOWN;