PackBits_pack_buffer()

This commit is contained in:
Thomas Bernard 2020-01-01 23:22:40 +01:00
parent 0dcee6acc3
commit 59b029effe
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 20 additions and 0 deletions

View File

@ -180,3 +180,16 @@ int PackBits_pack_flush(T_PackBits_data * data)
} }
return data->output_count; return data->output_count;
} }
int PackBits_pack_buffer(FILE * f, const byte * buffer, size_t size)
{
T_PackBits_data pb_data;
PackBits_pack_init(&pb_data, f);
while (size-- > 0)
{
if (PackBits_pack_add(&pb_data, *buffer++))
return -1;
}
return PackBits_pack_flush(&pb_data);
}

View File

@ -70,4 +70,11 @@ int PackBits_pack_add(T_PackBits_data * data, byte b);
*/ */
int PackBits_pack_flush(T_PackBits_data * data); int PackBits_pack_flush(T_PackBits_data * data);
/**
* Pack a full buffer to FILE
* @param f FILE output or NULL (for no output)
* @return -1 for error, or the size of the packed stream so far
*/
int PackBits_pack_buffer(FILE * f, const byte * buffer, size_t size);
#endif #endif