diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2019-12-11 01:41:26 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2019-12-11 19:36:33 +0100 |
commit | 7542bb6bd597400167da57dc43dd37ff85a6e173 (patch) | |
tree | c8ba8ffc7ff08af3f3f3478f6ee98bf0fd5b7bb1 /kopete/protocols/msn/webcam/libmimic/bitstring.c | |
parent | fac887803df710a5ca534e0b79a5a274461e6697 (diff) | |
download | tdenetwork-7542bb6bd597400167da57dc43dd37ff85a6e173.tar.gz tdenetwork-7542bb6bd597400167da57dc43dd37ff85a6e173.zip |
kopete: Restore the MSN protocol because a replacement MSN server was created.
This reverts commits 0486034738 - 2d5f9c55da and f6fd4ab6c0.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 73f00336178a9f312bac2992649120d462e0ac2d)
Diffstat (limited to 'kopete/protocols/msn/webcam/libmimic/bitstring.c')
-rw-r--r-- | kopete/protocols/msn/webcam/libmimic/bitstring.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/kopete/protocols/msn/webcam/libmimic/bitstring.c b/kopete/protocols/msn/webcam/libmimic/bitstring.c new file mode 100644 index 00000000..7caf9fd8 --- /dev/null +++ b/kopete/protocols/msn/webcam/libmimic/bitstring.c @@ -0,0 +1,88 @@ +/* Copyright (C) 2005 Ole André Vadla Ravnås <oleavr@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "mimic-private.h" + +/* + * _read_bits + * + * Internal helper-function used to read num_bits + * from stream. + */ +guint32 _read_bits(MimCtx *ctx, gint num_bits) +{ + guint32 bits; + + if (ctx->cur_chunk_len >= 16) { + guchar *input_buf = (guchar *) ctx->data_buffer + ctx->data_index; + + if (!ctx->read_odd) { + ctx->read_odd = TRUE; + + ctx->cur_chunk = (input_buf[3] << 24) | + (input_buf[2] << 16) | + (input_buf[1] << 8) | + input_buf[0]; + + } else { + ctx->read_odd = FALSE; + + ctx->cur_chunk = (input_buf[1] << 24) | + (input_buf[0] << 16) | + (input_buf[7] << 8) | + input_buf[6]; + + ctx->data_index += 4; + } + + ctx->cur_chunk_len -= 16; + } + + bits = (ctx->cur_chunk << ctx->cur_chunk_len) >> (32 - num_bits); + ctx->cur_chunk_len += num_bits; + + return bits; +} + +/* + * _write_bits + * + * Internal helper-function used to write "length" + * bits of "bits" to stream. + */ +void _write_bits(MimCtx *ctx, guint32 bits, gint length) +{ + /* Left-align the bit string within its 32-bit container. */ + bits <<= (32 - length); + + /* Append the bit string (one or more of the trailing bits might not fit, but that's ok). */ + ctx->cur_chunk |= bits >> ctx->cur_chunk_len; + ctx->cur_chunk_len += length; + + /* Is it full? */ + if (ctx->cur_chunk_len >= 32) { + + /* Add the full 32-bit chunk to the stream and update counter. */ + ctx->chunk_ptr[0] = GUINT32_TO_LE(ctx->cur_chunk); + ctx->chunk_ptr++; + ctx->cur_chunk_len -= 32; + + /* Add any trailing bits that didn't fit. */ + ctx->cur_chunk = bits << (length - ctx->cur_chunk_len); + } +} + |