libintelprov/gpt/lib/cgpt_common.c
/* GUID conversion functions. Accepted format:
 *
 *   "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
 *
 * Returns CGPT_OK if parsing is successful; otherwise CGPT_FAILED.
 */
GUID conversion functions.

Returns CGPT_OK if parsing is successful; otherwise CGPT_FAILED.
GUID conversion functions . Returns CGPT_OK if parsing is successful ; otherwise CGPT_FAILED .
int StrToGuid(const char *str, Guid *guid) {
  uint32_t time_low;
  uint16_t time_mid;
  uint16_t time_high_and_version;
  unsigned int chunk[11];
  if (11 != sscanf(str, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
                   chunk+0,
                   chunk+1,
                   chunk+2,
                   chunk+3,
                   chunk+4,
                   chunk+5,
                   chunk+6,
                   chunk+7,
                   chunk+8,
                   chunk+9,
                   chunk+10)) {
    printf("FAILED\n");
    return CGPT_FAILED;
  }
  time_low = chunk[0] & 0xffffffff;
  time_mid = chunk[1] & 0xffff;
  time_high_and_version = chunk[2] & 0xffff;
  guid->u.Uuid.time_low = htole32(time_low);
  guid->u.Uuid.time_mid = htole16(time_mid);
  guid->u.Uuid.time_high_and_version = htole16(time_high_and_version);
  guid->u.Uuid.clock_seq_high_and_reserved = chunk[3] & 0xff;
  guid->u.Uuid.clock_seq_low = chunk[4] & 0xff;
  guid->u.Uuid.node[0] = chunk[5] & 0xff;
  guid->u.Uuid.node[1] = chunk[6] & 0xff;
  guid->u.Uuid.node[2] = chunk[7] & 0xff;
  guid->u.Uuid.node[3] = chunk[8] & 0xff;
  guid->u.Uuid.node[4] = chunk[9] & 0xff;
  guid->u.Uuid.node[5] = chunk[10] & 0xff;
  return CGPT_OK;
}
int StrToGuid ( const char * str , Guid * guid ) { uint32_t time_low ; uint16_t time_mid ; uint16_t time_high_and_version ; unsigned int chunk [ 11 ] ; if ( 11 != sscanf ( str , " " , chunk + 0 , chunk + 1 , chunk + 2 , chunk + 3 , chunk + 4 , chunk + 5 , chunk + 6 , chunk + 7 , chunk + 8 , chunk + 9 , chunk + 10 ) ) { printf ( " \n " ) ; return CGPT_FAILED ; } time_low = chunk [ 0 ] & 0xffffffff ; time_mid = chunk [ 1 ] & 0xffff ; time_high_and_version = chunk [ 2 ] & 0xffff ; guid -> u . Uuid . time_low = htole32 ( time_low ) ; guid -> u . Uuid . time_mid = htole16 ( time_mid ) ; guid -> u . Uuid . time_high_and_version = htole16 ( time_high_and_version ) ; guid -> u . Uuid . clock_seq_high_and_reserved = chunk [ 3 ] & 0xff ; guid -> u . Uuid . clock_seq_low = chunk [ 4 ] & 0xff ; guid -> u . Uuid . node [ 0 ] = chunk [ 5 ] & 0xff ; guid -> u . Uuid . node [ 1 ] = chunk [ 6 ] & 0xff ; guid -> u . Uuid . node [ 2 ] = chunk [ 7 ] & 0xff ; guid -> u . Uuid . node [ 3 ] = chunk [ 8 ] & 0xff ; guid -> u . Uuid . node [ 4 ] = chunk [ 9 ] & 0xff ; guid -> u . Uuid . node [ 5 ] = chunk [ 10 ] & 0xff ; return CGPT_OK ; }
GUID conversion functions.
GUID conversion functions .