]> de.git.xonotic.org Git - xonotic/d0_blind_id.git/blobdiff - d0_iobuf.c
add a funny #ifdef RNG_XKCD that grounds the RNG
[xonotic/d0_blind_id.git] / d0_iobuf.c
index 67be0916acbe448da06c6945883d36e1c1821767..ce8e58d66912c6a82c6d17d036dad57c5cf15231 100644 (file)
@@ -1,21 +1,37 @@
 /*
-Blind-ID library for user identification using RSA blind signatures
-Copyright (C) 2010  Rudolf Polzer
-
-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 St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+ * FILE:       d0_iobuf.c
+ * AUTHOR:     Rudolf Polzer - divVerent@xonotic.org
+ * 
+ * Copyright (c) 2010, Rudolf Polzer
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Format:commit %H$
+ * $Id$
+ */
 
 #include "d0_iobuf.h"
 
@@ -26,7 +42,7 @@ struct d0_iobuf_s
        const unsigned char *inbuf;
        unsigned char *outbuf;
        size_t inpos, outpos, inbuflen, outbuflen;
-       BOOL ok;
+       D0_BOOL ok;
 };
 
 d0_iobuf_t *d0_iobuf_open_read(const void *buf, size_t len)
@@ -53,9 +69,9 @@ d0_iobuf_t *d0_iobuf_open_write(void *buf, size_t len)
        return b;
 }
 
-BOOL d0_iobuf_close(d0_iobuf_t *buf, size_t *len)
+D0_BOOL d0_iobuf_close(d0_iobuf_t *buf, size_t *len)
 {
-       BOOL r = buf->ok;
+       D0_BOOL r = buf->ok;
        if(len)
                *len = buf->outpos;
        d0_free(buf);
@@ -88,7 +104,7 @@ size_t d0_iobuf_read_raw(d0_iobuf_t *buf, void *s, size_t n)
        return nreal;
 }
 
-BOOL d0_iobuf_write_packet(d0_iobuf_t *buf, const void *s, size_t n)
+D0_BOOL d0_iobuf_write_packet(d0_iobuf_t *buf, const void *s, size_t n)
 {
        unsigned char c;
        size_t nn = n;
@@ -106,7 +122,7 @@ BOOL d0_iobuf_write_packet(d0_iobuf_t *buf, const void *s, size_t n)
        return 1;
 }
 
-BOOL d0_iobuf_read_packet(d0_iobuf_t *buf, void *s, size_t *np)
+D0_BOOL d0_iobuf_read_packet(d0_iobuf_t *buf, void *s, size_t *np)
 {
        unsigned char c;
        size_t n = 0;
@@ -127,7 +143,7 @@ BOOL d0_iobuf_read_packet(d0_iobuf_t *buf, void *s, size_t *np)
        return 1;
 }
 
-BOOL d0_iobuf_conv_base64_in(d0_iobuf_t *buf)
+D0_BOOL d0_iobuf_conv_base64_in(d0_iobuf_t *buf)
 {
        // compand the in-buffer
        return 0;
@@ -149,7 +165,7 @@ static void base64_3to4(const unsigned char *in, unsigned char *out, int bytes)
        out[3] = (bytes > 2) ? o3 : '=';
 }
 
-BOOL d0_iobuf_conv_base64_out(d0_iobuf_t *buf)
+D0_BOOL d0_iobuf_conv_base64_out(d0_iobuf_t *buf)
 {
        size_t blocks, i;
        // expand the out-buffer