Home | History | Annotate | Line # | Download | only in cgdconfig
utils.h revision 1.3
      1  1.3     cb /* $NetBSD: utils.h,v 1.3 2003/09/23 17:24:46 cb Exp $ */
      2  1.1  elric 
      3  1.1  elric /*-
      4  1.2  elric  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
      5  1.1  elric  * All rights reserved.
      6  1.1  elric  *
      7  1.1  elric  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  elric  * by Roland C. Dowdeswell.
      9  1.1  elric  *
     10  1.1  elric  * Redistribution and use in source and binary forms, with or without
     11  1.1  elric  * modification, are permitted provided that the following conditions
     12  1.1  elric  * are met:
     13  1.1  elric  * 1. Redistributions of source code must retain the above copyright
     14  1.1  elric  *    notice, this list of conditions and the following disclaimer.
     15  1.1  elric  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  elric  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  elric  *    documentation and/or other materials provided with the distribution.
     18  1.1  elric  * 3. All advertising materials mentioning features or use of this software
     19  1.1  elric  *    must display the following acknowledgement:
     20  1.1  elric  *        This product includes software developed by the NetBSD
     21  1.1  elric  *        Foundation, Inc. and its contributors.
     22  1.1  elric  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  elric  *    contributors may be used to endorse or promote products derived
     24  1.1  elric  *    from this software without specific prior written permission.
     25  1.1  elric  *
     26  1.1  elric  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  elric  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  elric  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  elric  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  elric  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  elric  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  elric  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  elric  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  elric  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  elric  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  elric  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  elric  */
     38  1.1  elric 
     39  1.2  elric #ifndef CGDUTILS_H
     40  1.2  elric #define CGDUTILS_H
     41  1.1  elric 
     42  1.2  elric #include <stdio.h>
     43  1.1  elric 
     44  1.1  elric #define BITS2BYTES(n)	(((n) + 7) / 8)
     45  1.2  elric 
     46  1.2  elric struct string;
     47  1.2  elric typedef struct string string_t;
     48  1.2  elric 
     49  1.2  elric struct bits;
     50  1.2  elric typedef struct bits bits_t;
     51  1.2  elric 
     52  1.2  elric __BEGIN_DECLS
     53  1.2  elric char		**words(const char *, int *);
     54  1.2  elric void	  	  words_free(char **, int);
     55  1.2  elric 
     56  1.2  elric void		  memxor(void *, const void *, size_t);
     57  1.2  elric 
     58  1.2  elric void		  free_notnull(void *);
     59  1.2  elric 
     60  1.2  elric string_t	 *string_new(const char *, int);
     61  1.2  elric string_t	 *string_dup(const string_t *);
     62  1.2  elric void		  string_assign(string_t **, string_t *);
     63  1.2  elric void		  string_free(string_t *);
     64  1.2  elric string_t	 *string_add(const string_t *, const string_t *);
     65  1.2  elric string_t	 *string_add_d(string_t *, string_t *);
     66  1.2  elric string_t	 *string_fromcharstar(const char *);
     67  1.2  elric const char	 *string_tocharstar(const string_t *);
     68  1.2  elric string_t	 *string_fromint(int);
     69  1.2  elric 
     70  1.2  elric void		  string_fprint(FILE *, const string_t *);
     71  1.2  elric 
     72  1.2  elric bits_t		 *bits_new(const void *, int);
     73  1.2  elric bits_t		 *bits_dup(const bits_t *);
     74  1.2  elric void		  bits_assign(bits_t **, bits_t *);
     75  1.2  elric void		  bits_free(bits_t *);
     76  1.2  elric const void	 *bits_getbuf(bits_t *);
     77  1.2  elric int		  bits_len(bits_t *);
     78  1.3     cb int		  bits_match(const bits_t *, const bits_t *);
     79  1.2  elric 
     80  1.2  elric bits_t		 *bits_xor(const bits_t *, const bits_t *);
     81  1.2  elric bits_t		 *bits_xor_d(bits_t *, bits_t *);
     82  1.2  elric 
     83  1.2  elric bits_t		 *bits_decode(const string_t *);
     84  1.2  elric bits_t		 *bits_decode_d(string_t *);
     85  1.2  elric string_t	 *bits_encode(const bits_t *);
     86  1.2  elric string_t	 *bits_encode_d(bits_t *);
     87  1.2  elric 
     88  1.2  elric bits_t		 *bits_cget(const char *, int);
     89  1.2  elric bits_t		 *bits_fget(FILE *, int);
     90  1.2  elric bits_t		 *bits_getrandombits(int);
     91  1.2  elric 
     92  1.2  elric void		  bits_fprint(FILE *, const bits_t *);
     93  1.2  elric __END_DECLS
     94  1.2  elric 
     95  1.2  elric #endif
     96