Пример #1
0
void Ebml_WriteString(EbmlGlobal *glob, const char *str) {
  const size_t size_ = strlen(str);
  const uint64_t  size = size_;
  Ebml_WriteLen(glob, size);
  /* TODO: it's not clear from the spec whether the nul terminator
   * should be serialized too.  For now we omit the null terminator.
   */
  Ebml_Write(glob, str, (unsigned long)size);
}
Пример #2
0
/* TODO: perhaps this is a poor name for this id serializer helper function */
void Ebml_SerializeBinary(EbmlGlobal *glob, unsigned long class_id, unsigned long bin) {
  int size;
  for (size = 4; size > 1; size--) {
    if (bin & (unsigned int)0x000000ff << ((size - 1) * 8))
      break;
  }
  Ebml_WriteID(glob, class_id);
  Ebml_WriteLen(glob, size);
  Ebml_WriteID(glob, bin);
}
Пример #3
0
void Ebml_WriteUTF8(EbmlGlobal *glob, const wchar_t *wstr) {
  const size_t strlen = wcslen(wstr);

  /* TODO: it's not clear from the spec whether the nul terminator
   * should be serialized too.  For now we include it.
   */
  const uint64_t  size = strlen;

  Ebml_WriteLen(glob, size);
  Ebml_Write(glob, wstr, (unsigned long)size);
}
Пример #4
0
void Ebml_WriteVoid(EbmlGlobal *glob, unsigned long vSize) {
  unsigned char tmp = 0;
  unsigned long i = 0;

  Ebml_WriteID(glob, 0xEC);
  Ebml_WriteLen(glob, vSize);

  for (i = 0; i < vSize; i++) {
    Ebml_Write(glob, &tmp, 1);
  }
}
Пример #5
0
void Ebml_SerializeData(EbmlGlobal *glob, unsigned long class_id, unsigned char *data, unsigned long data_length)
{
    Ebml_WriteID(glob, class_id);
    Ebml_WriteLen(glob, data_length);
    Ebml_Write(glob,  data, data_length);
}