\hypertarget{binstream_8c_source}{}\doxysection{binstream.\+c}
\label{binstream_8c_source}\index{geom/virstor/binstream.c@{geom/virstor/binstream.c}}
\mbox{\hyperlink{binstream_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2005 Ivan Voras <ivoras@gmail.com>}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00029}00029 \textcolor{comment}{// \$Id: binstream.c,v 1.1 2006/07/05 10:47:54 ivoras Exp \$}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00032}\mbox{\hyperlink{binstream_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00032}} \mbox{\hyperlink{binstream_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/endian.h>}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{binstream_8h}{geom/virstor/binstream.h}}>}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00039}00039 \textcolor{comment}{/* "{}Open"{} a binary stream for reading */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00040}00040 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00041}\mbox{\hyperlink{binstream_8c_a34310e3fff53a416f50f8224e0cad834}{00041}} \mbox{\hyperlink{binstream_8c_a34310e3fff53a416f50f8224e0cad834}{bs\_open}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \textcolor{keywordtype}{void} *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00042}00042 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00043}00043         bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} = (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00044}00044         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} = 0;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00045}00045 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00047}00047 \textcolor{comment}{/* "{}Reset"{} position in binary stream to zero */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00048}00048 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00049}\mbox{\hyperlink{binstream_8c_a5506b5ea42af5eac97bd402e45f56fcf}{00049}} \mbox{\hyperlink{binstream_8c_a5506b5ea42af5eac97bd402e45f56fcf}{bs\_reset}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00050}00050 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00051}00051         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} = 0;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00052}00052 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00053}00053 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00054}00054 \textcolor{comment}{/* Write a zero-\/terminated string; return next position */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00055}00055 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00056}\mbox{\hyperlink{binstream_8c_ab97cfcc47d9ab93c310b9aeb994f230d}{00056}} \mbox{\hyperlink{binstream_8c_ab97cfcc47d9ab93c310b9aeb994f230d}{bs\_write\_str}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00057}00057 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00058}00058         \textcolor{keywordtype}{int}             len = 0;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00059}00059         \textcolor{keywordflow}{do} \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00060}00060                 *(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} + len) = *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00061}00061                 len++;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00062}00062         \} \textcolor{keywordflow}{while} (*(\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}++) != \textcolor{charliteral}{'\(\backslash\)0'});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00063}00063         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += len;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00064}00064         \textcolor{keywordflow}{return} bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00065}00065 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00067}00067 \textcolor{comment}{/* Write an arbitrary buffer; return next position */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00068}00068 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00069}\mbox{\hyperlink{binstream_8c_abeae2577db74244a9e94ecc7f7daef34}{00069}} \mbox{\hyperlink{binstream_8c_abeae2577db74244a9e94ecc7f7daef34}{bs\_write\_buf}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}, \textcolor{keywordtype}{unsigned} data\_size)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00070}00070 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00071}00071         \textcolor{keywordtype}{unsigned}        i;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00072}00072         \textcolor{keywordflow}{for} (i = 0; i < data\_size; i++)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00073}00073                 *(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} + i) = *(\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + i);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00074}00074         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += data\_size;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00075}00075         \textcolor{keywordflow}{return} bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00076}00076 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00077}00077 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00078}00078 \textcolor{comment}{/* Write a 8bit uint; return next position. */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00079}00079 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00080}\mbox{\hyperlink{binstream_8c_a3c0c37af2595f6da908b89f2940cfa66}{00080}} \mbox{\hyperlink{binstream_8c_a3c0c37af2595f6da908b89f2940cfa66}{bs\_write\_u8}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}} \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00081}00081 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00082}00082         *((\mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}} *) (bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}})) = \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00083}00083         \textcolor{keywordflow}{return} ++(bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00084}00084 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00086}00086 \textcolor{comment}{/* Write a 16bit uint; return next position. */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00087}00087 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00088}\mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{00088}} \mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{bs\_write\_u16}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, uint16\_t \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00089}00089 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00090}00090         le16enc(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}}, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00091}00091         \textcolor{keywordflow}{return} (bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 2);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00092}00092 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00093}00093 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00094}00094 \textcolor{comment}{/* Write a 32bit uint; return next position. */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00095}00095 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00096}\mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{00096}} \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, uint32\_t \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00097}00097 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00098}00098         le32enc(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}}, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00099}00099         \textcolor{keywordflow}{return} (bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 4);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00100}00100 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00102}00102 \textcolor{comment}{/* Write a 64bit uint; return next position. */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00103}00103 \textcolor{keywordtype}{unsigned}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00104}\mbox{\hyperlink{binstream_8c_a51b8c8ff5832c4303922ffa9eda08bbe}{00104}} \mbox{\hyperlink{binstream_8c_a51b8c8ff5832c4303922ffa9eda08bbe}{bs\_write\_u64}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, uint64\_t \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00105}00105 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00106}00106         le64enc(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}}, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00107}00107         \textcolor{keywordflow}{return} (bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 8);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00108}00108 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00109}00109 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00110}00110 \textcolor{comment}{/* Read a 8bit uint \& return it */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00111}00111 \mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00112}\mbox{\hyperlink{binstream_8c_a15b2e022a0bf00be48b71d328c1823cf}{00112}} \mbox{\hyperlink{binstream_8c_a15b2e022a0bf00be48b71d328c1823cf}{bs\_read\_u8}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00113}00113 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00114}00114         \mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}}          \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = *((\mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}} *) (bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}}));}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00115}00115         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}}++;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00116}00116         \textcolor{keywordflow}{return} \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00117}00117 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00118}00118 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00119}00119 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00120}00120 \textcolor{comment}{ * Read a null-\/terminated string from stream into a buffer; buf\_size is size}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00121}00121 \textcolor{comment}{ * of the buffer, including the final \(\backslash\)0. Returns buf pointer or NULL if}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00122}00122 \textcolor{comment}{ * garbage input.}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00123}00123 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00124}00124 \textcolor{keywordtype}{char}*}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00125}\mbox{\hyperlink{binstream_8c_aa44886e1be513c868d53520ff3f2ebf4}{00125}} \mbox{\hyperlink{binstream_8c_aa44886e1be513c868d53520ff3f2ebf4}{bs\_read\_str}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}}, \textcolor{keywordtype}{unsigned} buf\_size)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00126}00126 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00127}00127         \textcolor{keywordtype}{unsigned}        len = 0;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00128}00128         \textcolor{keywordtype}{char}           *work\_buf = \mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00129}00129         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}} == NULL || buf\_size < 1)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00130}00130                 \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00131}00131         \textcolor{keywordflow}{do} \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00132}00132                 *work\_buf = *(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} + len);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00133}00133         \} \textcolor{keywordflow}{while} (len++ < buf\_size -\/ 1 \&\& *(work\_buf++) != \textcolor{charliteral}{'\(\backslash\)0'});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00134}00134         *(\mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}} + buf\_size -\/ 1) = \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00135}00135         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += len;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00136}00136         \textcolor{keywordflow}{return} \mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00137}00137 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00139}00139 \textcolor{comment}{/* Read an arbitrary buffer. */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00140}00140 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00141}\mbox{\hyperlink{binstream_8c_a32a576befe71da767c85299534312670}{00141}} \mbox{\hyperlink{binstream_8c_a32a576befe71da767c85299534312670}{bs\_read\_buf}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs, \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}}, \textcolor{keywordtype}{unsigned} buf\_size)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00142}00142 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00143}00143         \textcolor{keywordtype}{unsigned}        i;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00144}00144         \textcolor{keywordflow}{for} (i = 0; i < buf\_size; i++)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00145}00145                 *(\mbox{\hyperlink{g__part__if_8m_ac14417684334d01b4e1e807a19d92816}{buf}} + i) = *(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} + i);}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00146}00146         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += buf\_size;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00147}00147 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00148}00148 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00149}00149 \textcolor{comment}{/* Read a 16bit uint \& return it */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00150}00150 uint16\_t}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00151}\mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{00151}} \mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{bs\_read\_u16}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00152}00152 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00153}00153         uint16\_t        \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = le16dec(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00154}00154         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 2;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00155}00155         \textcolor{keywordflow}{return} \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00156}00156 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00158}00158 \textcolor{comment}{/* Read a 32bit uint \& return it */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00159}00159 uint32\_t}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00160}\mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{00160}} \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00161}00161 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00162}00162         uint32\_t        \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = le32dec(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00163}00163         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 4;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00164}00164         \textcolor{keywordflow}{return} \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00165}00165 \}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00166}00166 }
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00167}00167 \textcolor{comment}{/* Read a 64bit uint \& return it */}}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00168}00168 uint64\_t}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00169}\mbox{\hyperlink{binstream_8c_a3816c3b239b7062a2ceadf02ab83622b}{00169}} \mbox{\hyperlink{binstream_8c_a3816c3b239b7062a2ceadf02ab83622b}{bs\_read\_u64}}(\mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} * bs)}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00170}00170 \{}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00171}00171         uint64\_t        \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = le64dec(bs-\/>\mbox{\hyperlink{structbin__stream__t_a0e0ea417c95fee91663e1f2bdabd4fcd}{data}} + bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}});}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00172}00172         bs-\/>\mbox{\hyperlink{structbin__stream__t_af247431475ea789da16dd5bee6229ea3}{pos}} += 8;}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00173}00173         \textcolor{keywordflow}{return} \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}};}
\DoxyCodeLine{\Hypertarget{binstream_8c_source_l00174}00174 \}}

\end{DoxyCode}
