Esempio n. 1
0
size_t
base32_decode (uint8_t *output, const size_t outputLength, const uint8_t *input, const size_t inputLength)
{
  if (outputLength == 0 || inputLength == 0 || inputLength % 8 != 0)
    return 0;

  size_t bytes = 0;
  uint8_t currentByte = 0;
  unsigned offset;
  for (offset = 0; offset < inputLength && bytes < outputLength; offset += 8)
  {
    output[bytes] = decode_bits (input[offset + 0]) << 3;
    currentByte = decode_bits (input[offset + 1]);
    output[bytes] += currentByte >> 2;
    output[bytes + 1] = (currentByte & 0x03) << 6;

    if (input[offset + 2] == '=')
      return bytes + 1;
    else
      bytes++;

    output[bytes] += decode_bits (input[offset + 2]) << 1;
    currentByte = decode_bits (input[offset + 3]);
    output[bytes] += currentByte >> 4;
    output[bytes + 1] = currentByte << 4;

    if (input[offset + 4] == '=')
      return bytes + 1;
    else
      bytes++;

    currentByte = decode_bits (input[offset + 4]);
    output[bytes] += currentByte >> 1;
    output[bytes + 1] = currentByte << 7;

    if (input[offset + 5] == '=')
      return bytes + 1;
    else
      bytes++;

    output[bytes] += decode_bits (input[offset + 5]) << 2;
    currentByte = decode_bits (input[offset + 6]);
    output[bytes] +=  currentByte >> 3;
    output[bytes + 1] = (currentByte & 0x07) << 5;

    if (input[offset + 7] == '=')
      return bytes + 1;
    else
      bytes++;

    output[bytes] += decode_bits (input[offset + 7]) & 0x1F;
    bytes++;
  }
  return bytes;
}
Esempio n. 2
0
//Sam Meizlish and Zack SHeldon 10/16/15
int main (void)
{
    int c;
    while ( (c = getchar() ) != EOF )
    {
        //printf( "%d", c );
        decode_bits( c );
    }
}
Esempio n. 3
0
/* Decode TXCSR register.
 */
static char *decode_txcsr(u16 txcsr)
{
	static char buf[256];
	sprintf(buf, "%s (%s%s%s%s)",
		decode_bits(txcsr),
		txcsr & MGC_M_TXCSR_TXPKTRDY ? "[TXPKTRDY]" : "",
		txcsr & MGC_M_TXCSR_AUTOSET ? "[MGC_M_TXCSR_AUTOSET]" : "",
		txcsr & MGC_M_TXCSR_DMAENAB ? "[MGC_M_TXCSR_DMAENAB]" : "",
		txcsr & MGC_M_TXCSR_DMAMODE ? "[MGC_M_TXCSR_DMAMODE]" : "");
	return buf;
}
Esempio n. 4
0
static void oh_fumi_access_prot_mask(SaHpiFumiProtocolT mask, char *buf, int bufsize)
{
    SaHpiFumiProtocolT decoded = 0;

    if ( mask == 0 ) {
        return;
    }
    strncpy( buf, "{", bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_TFTP, " TFTP ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_FTP, " FTP ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_HTTP, " HTTP ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_LDAP, " LDAP ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_LOCAL, " LOCAL ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_NFS, " NFS ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_PROT_DBACCESS, " DBACCESS ", &decoded, buf, bufsize );
    decode_bits( mask, mask ^ decoded, " UNKNOWN ", &decoded, buf, bufsize );
    strncat( buf, "}", bufsize );
}
Esempio n. 5
0
static void decode_ICR(unsigned int val)
{
	decode_bits(KERN_DEBUG "ICR", icr_bits, ARRAY_SIZE(icr_bits), val);
	printk("\n");
}
Esempio n. 6
0
static void oh_fumi_caps_mask(SaHpiFumiCapabilityT mask, char *buf, int bufsize)
{
    SaHpiFumiCapabilityT decoded = 0;

    if ( mask == 0 ) {
        return;
    }
    strncpy( buf, "{", bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_ROLLBACK,
                 " ROLLBACK ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_BANKCOPY,
                 " BANKCOPY ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_BANKREORDER,
                 " BANKREORDER ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_BACKUP,
                 " BACKUP ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_TARGET_VERIFY,
                 " TARGET_VERIFY ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_TARGET_VERIFY_MAIN,
                 " TARGET_VERIFY_MAIN ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_COMPONENTS,
                 " COMPONENTS ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_AUTOROLLBACK,
                 " AUTOROLLBACK ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_AUTOROLLBACK_CAN_BE_DISABLED,
                 " AUTOROLLBACK_CAN_BE_DISABLED ", &decoded, buf, bufsize );
    decode_bits( mask, SAHPI_FUMI_CAP_MAIN_NOT_PERSISTENT,
                 " MAIN_NOT_PERSISTENT ", &decoded, buf, bufsize );
    decode_bits( mask, mask ^ decoded,
                 " UNKNOWN ", &decoded, buf, bufsize );
    strncat( buf, "}", bufsize );
}