Reformat and normalize licenses and headerss
This commit is purely aestetic/taste, nothing important. I don't really like this *huge* license at the top of every file but I guess it must stay so add it to some files where it wasn't included so they are the same. Slightly reformat them. Unindent extra indentation found in some headers. Strip trailing whitespace in files and enabled setting in editor, which caused a lot of noise in this commit but that should be the end of it. Remove the comment at the top of each file that said who created it and when (it will remain in VCS history for reference and was always Don who created the files).
This commit is contained in:
parent
eb89c4bf8e
commit
01d2b274b7
73
src/cfu.c
73
src/cfu.c
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-07-09 21:44:59
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfu.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfu.h"
|
||||
|
||||
struct libcfu_item {
|
||||
|
73
src/cfu.h
73
src/cfu.h
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-07-06 07:34:51
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfu.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCFU_H_
|
||||
#define _LIBCFU_H_
|
||||
|
||||
|
@ -1,44 +1,40 @@
|
||||
/* Creation date: 2005-07-08 22:23:31
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuconf.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfu.h"
|
||||
#include "cfuconf.h"
|
||||
|
||||
|
169
src/cfuconf.h
169
src/cfuconf.h
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-07-08 22:24:03
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuconf.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFU_CONF_H_
|
||||
#define _CFU_CONF_H_
|
||||
|
||||
@ -48,72 +45,72 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
struct cfuconf;
|
||||
typedef struct cfuconf cfuconf_t;
|
||||
struct cfuconf;
|
||||
typedef struct cfuconf cfuconf_t;
|
||||
|
||||
/* Apache-style conf files contain directives and containers.
|
||||
Directives are simple one line specifications with or without
|
||||
arguments, e.g.,
|
||||
/* Apache-style conf files contain directives and containers.
|
||||
Directives are simple one line specifications with or without
|
||||
arguments, e.g.,
|
||||
|
||||
Doit
|
||||
Expires On
|
||||
LoadModule my_mod modules/my_mod.so
|
||||
Doit
|
||||
Expires On
|
||||
LoadModule my_mod modules/my_mod.so
|
||||
|
||||
Containers have a type and a name associated with them and they
|
||||
in turn contain directives and/or containers, e.g.,
|
||||
Containers have a type and a name associated with them and they
|
||||
in turn contain directives and/or containers, e.g.,
|
||||
|
||||
<MyContainer test1>
|
||||
Expires Off
|
||||
<DB devdb>
|
||||
DBHost db.example.com
|
||||
DBUser test_user
|
||||
</DB>
|
||||
</MyContainer>
|
||||
<MyContainer test1>
|
||||
Expires Off
|
||||
<DB devdb>
|
||||
DBHost db.example.com
|
||||
DBUser test_user
|
||||
</DB>
|
||||
</MyContainer>
|
||||
|
||||
Values may be quoted, e.g.
|
||||
Values may be quoted, e.g.
|
||||
|
||||
DBUser "test user"
|
||||
DBUser "test user"
|
||||
|
||||
But must be specified on a single line. To escape quotes
|
||||
within a quoted string, use the '\' character.
|
||||
But must be specified on a single line. To escape quotes
|
||||
within a quoted string, use the '\' character.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
/* Parse the apache-like conf file specified by file_path,
|
||||
* returning a pointer to a cfuconf_t structure in conf. Returns
|
||||
* zero on success, less than zero on error. If an error occurs
|
||||
* and error is not NULL, it will be set to an error message
|
||||
* (which must be free()'d by the caller).
|
||||
*/
|
||||
extern int cfuconf_parse_file(char *file_path, cfuconf_t **conf, char **error);
|
||||
/* Parse the apache-like conf file specified by file_path,
|
||||
* returning a pointer to a cfuconf_t structure in conf. Returns
|
||||
* zero on success, less than zero on error. If an error occurs
|
||||
* and error is not NULL, it will be set to an error message
|
||||
* (which must be free()'d by the caller).
|
||||
*/
|
||||
extern int cfuconf_parse_file(char *file_path, cfuconf_t **conf, char **error);
|
||||
|
||||
/* Same as cfuconf_parse_file(), except assume the contents of the
|
||||
* file are already in buffer.
|
||||
*/
|
||||
extern int cfuconf_parse_buffer(char *buffer, cfuconf_t **conf, char **error);
|
||||
/* Same as cfuconf_parse_file(), except assume the contents of the
|
||||
* file are already in buffer.
|
||||
*/
|
||||
extern int cfuconf_parse_buffer(char *buffer, cfuconf_t **conf, char **error);
|
||||
|
||||
/* Free all resources used by the cfuconf_t structure */
|
||||
extern void cfuconf_destroy(cfuconf_t *conf);
|
||||
/* Free all resources used by the cfuconf_t structure */
|
||||
extern void cfuconf_destroy(cfuconf_t *conf);
|
||||
|
||||
/* Get a hash of containers at the top level of conf */
|
||||
extern cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf);
|
||||
/* Get a hash of containers at the top level of conf */
|
||||
extern cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf);
|
||||
|
||||
/* Get a hash of directives at the to level */
|
||||
extern cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf);
|
||||
/* Get a hash of directives at the to level */
|
||||
extern cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf);
|
||||
|
||||
/* Get the value of the given directive, assuming there is only one argument */
|
||||
extern int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue);
|
||||
/* Get the value of the given directive, assuming there is only one argument */
|
||||
extern int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue);
|
||||
|
||||
/* Get the value of the given directive, assuming there are two arguments */
|
||||
extern int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue,
|
||||
char **rvalue2);
|
||||
/* Get the value of the given directive, assuming there are two arguments */
|
||||
extern int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue,
|
||||
char **rvalue2);
|
||||
|
||||
/* Get the value of the given directives, with n arguments */
|
||||
extern int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...);
|
||||
/* Get the value of the given directives, with n arguments */
|
||||
extern int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...);
|
||||
|
||||
/* Print out a representation of the parsed configuration */
|
||||
extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level);
|
||||
/* Print out a representation of the parsed configuration */
|
||||
extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level);
|
||||
|
||||
CFU_END_DECLS
|
||||
|
||||
|
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-24 21:22:40
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuhash.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
417
src/cfuhash.h
417
src/cfuhash.h
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-24 21:22:09
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuhash.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFU_HASH_H_
|
||||
#define _CFU_HASH_H_
|
||||
|
||||
@ -47,215 +44,215 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
/* The hash table itself. */
|
||||
struct cfuhash_table;
|
||||
typedef struct cfuhash_table cfuhash_table_t;
|
||||
/* The hash table itself. */
|
||||
struct cfuhash_table;
|
||||
typedef struct cfuhash_table cfuhash_table_t;
|
||||
|
||||
/* Prototype for a pointer to a hashing function. */
|
||||
typedef u_int32_t (*cfuhash_function_t)(const void *key, size_t length);
|
||||
/* Prototype for a pointer to a hashing function. */
|
||||
typedef u_int32_t (*cfuhash_function_t)(const void *key, size_t length);
|
||||
|
||||
/* Prototype for a pointer to a free function. */
|
||||
typedef void (*cfuhash_free_fn_t)(void *data);
|
||||
/* Prototype for a pointer to a free function. */
|
||||
typedef void (*cfuhash_free_fn_t)(void *data);
|
||||
|
||||
/* Prototype for a pointer to a function that determines whether
|
||||
* or not to remove an entry from the hash.
|
||||
*/
|
||||
typedef int (*cfuhash_remove_fn_t)(void *key, size_t key_size, void *data, size_t data_size,
|
||||
void *arg);
|
||||
/* Prototype for a pointer to a function that determines whether
|
||||
* or not to remove an entry from the hash.
|
||||
*/
|
||||
typedef int (*cfuhash_remove_fn_t)(void *key, size_t key_size, void *data, size_t data_size,
|
||||
void *arg);
|
||||
|
||||
/* Prototype for a pointer to a function to be called foreach
|
||||
* key/value pair in the hash by cfuhash_foreach(). Iteration
|
||||
* stops if a non-zero value is returned.
|
||||
*/
|
||||
typedef int (*cfuhash_foreach_fn_t)(void *key, size_t key_size, void *data, size_t data_size,
|
||||
void *arg);
|
||||
/* Prototype for a pointer to a function to be called foreach
|
||||
* key/value pair in the hash by cfuhash_foreach(). Iteration
|
||||
* stops if a non-zero value is returned.
|
||||
*/
|
||||
typedef int (*cfuhash_foreach_fn_t)(void *key, size_t key_size, void *data, size_t data_size,
|
||||
void *arg);
|
||||
|
||||
/* Creates a new hash table. */
|
||||
extern cfuhash_table_t * cfuhash_new();
|
||||
/* Creates a new hash table. */
|
||||
extern cfuhash_table_t * cfuhash_new();
|
||||
|
||||
/* Creates a new hash table with the specified size (number of
|
||||
* buckets).
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_new_with_initial_size(size_t size);
|
||||
/* Creates a new hash table with the specified size (number of
|
||||
* buckets).
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_new_with_initial_size(size_t size);
|
||||
|
||||
/* Creates a new hash table with the specified flags. Pass zero
|
||||
* for flags if you want the defaults.
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags);
|
||||
/* Creates a new hash table with the specified flags. Pass zero
|
||||
* for flags if you want the defaults.
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags);
|
||||
|
||||
/* Same as cfuhash_new() except automatically calls cfuhash_set_free_fn(). */
|
||||
extern cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff);
|
||||
/* Same as cfuhash_new() except automatically calls cfuhash_set_free_fn(). */
|
||||
extern cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff);
|
||||
|
||||
/* Copies entries in src to dst */
|
||||
extern int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst);
|
||||
/* Copies entries in src to dst */
|
||||
extern int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst);
|
||||
|
||||
/* Returns a new hash containing entries from both hash tables.
|
||||
* For any entries with the same key, the one from ht2 wins.
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2,
|
||||
u_int32_t flags);
|
||||
/* Returns a new hash containing entries from both hash tables.
|
||||
* For any entries with the same key, the one from ht2 wins.
|
||||
*/
|
||||
extern cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2,
|
||||
u_int32_t flags);
|
||||
|
||||
/* Sets the hashing function to use when computing which bucket to add
|
||||
* entries to. It should return a 32-bit unsigned integer. By
|
||||
* default, Perl's hashing algorithm is used.
|
||||
*/
|
||||
extern int cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf);
|
||||
/* Sets the hashing function to use when computing which bucket to add
|
||||
* entries to. It should return a 32-bit unsigned integer. By
|
||||
* default, Perl's hashing algorithm is used.
|
||||
*/
|
||||
extern int cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf);
|
||||
|
||||
/* Sets the thresholds for when to rehash. The ratio
|
||||
* num_entries/buckets is compared against low and high. If it is
|
||||
* below 'low' or above 'high', the hash will shrink or grow,
|
||||
* respectively, unless the flags say to do otherwise.
|
||||
*/
|
||||
extern int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high);
|
||||
/* Sets the thresholds for when to rehash. The ratio
|
||||
* num_entries/buckets is compared against low and high. If it is
|
||||
* below 'low' or above 'high', the hash will shrink or grow,
|
||||
* respectively, unless the flags say to do otherwise.
|
||||
*/
|
||||
extern int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high);
|
||||
|
||||
/* Sets the function to use when removing an entry from the hash,
|
||||
* i.e., when replacing an existing entry, deleting an entry, or
|
||||
* clearing the hash. It is passed the value of the entry as a
|
||||
* void *.
|
||||
*/
|
||||
extern int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff);
|
||||
/* Sets the function to use when removing an entry from the hash,
|
||||
* i.e., when replacing an existing entry, deleting an entry, or
|
||||
* clearing the hash. It is passed the value of the entry as a
|
||||
* void *.
|
||||
*/
|
||||
extern int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff);
|
||||
|
||||
/* Returns the hash's flags. See below for flag definitions. */
|
||||
extern u_int32_t cfuhash_get_flags(cfuhash_table_t *ht);
|
||||
/* Returns the hash's flags. See below for flag definitions. */
|
||||
extern u_int32_t cfuhash_get_flags(cfuhash_table_t *ht);
|
||||
|
||||
/* Sets a flag. */
|
||||
extern u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t flag);
|
||||
/* Sets a flag. */
|
||||
extern u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t flag);
|
||||
|
||||
/* Clears a flag. */
|
||||
extern u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag);
|
||||
/* Clears a flag. */
|
||||
extern u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag);
|
||||
|
||||
/* Returns the value for the entry with given key. If key_size is -1,
|
||||
* key is assumed to be a null-terminated string. If data_size is not
|
||||
* NULL, the size of the value is placed into data_size.
|
||||
*/
|
||||
extern int cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size,
|
||||
void **data, size_t *data_size);
|
||||
/* Returns the value for the entry with given key. If key_size is -1,
|
||||
* key is assumed to be a null-terminated string. If data_size is not
|
||||
* NULL, the size of the value is placed into data_size.
|
||||
*/
|
||||
extern int cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size,
|
||||
void **data, size_t *data_size);
|
||||
|
||||
/* Returns 1 if an entry with the given key exists in the hash, 0 otherwise. */
|
||||
extern int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size);
|
||||
/* Returns 1 if an entry with the given key exists in the hash, 0 otherwise. */
|
||||
extern int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size);
|
||||
|
||||
/* Inserts the given data value into the hash and associates it with
|
||||
* key. If key_size is -1, key is assumed to be a null-terminated
|
||||
* string. If data_size is -1, it is assumed to be a null-terminated
|
||||
* string (it's length will be calculated using strlen). If
|
||||
* data_size is zero, it will be returned as zero when the value is
|
||||
* requested.
|
||||
*/
|
||||
extern int cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *data,
|
||||
size_t data_size, void **r);
|
||||
/* Inserts the given data value into the hash and associates it with
|
||||
* key. If key_size is -1, key is assumed to be a null-terminated
|
||||
* string. If data_size is -1, it is assumed to be a null-terminated
|
||||
* string (it's length will be calculated using strlen). If
|
||||
* data_size is zero, it will be returned as zero when the value is
|
||||
* requested.
|
||||
*/
|
||||
extern int cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *data,
|
||||
size_t data_size, void **r);
|
||||
|
||||
/* Clears the hash table (deletes all entries). */
|
||||
extern void cfuhash_clear(cfuhash_table_t *ht);
|
||||
/* Clears the hash table (deletes all entries). */
|
||||
extern void cfuhash_clear(cfuhash_table_t *ht);
|
||||
|
||||
/* Deletes the entry in the hash associated with key. If the entry
|
||||
* existed, it's value will be returned.
|
||||
*/
|
||||
extern void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size);
|
||||
/* Deletes the entry in the hash associated with key. If the entry
|
||||
* existed, it's value will be returned.
|
||||
*/
|
||||
extern void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size);
|
||||
|
||||
/* Returns all the keys from the hash. The number of keys is placed
|
||||
* into the value pointed to by num_keys. If key_sizes is not NULL,
|
||||
* it will be set to an array of key sizes. If fast is zero, copies
|
||||
* of the keys are returned. Otherwise, pointers to the real keys
|
||||
* will be returned.
|
||||
*/
|
||||
extern void **cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes,
|
||||
int fast);
|
||||
/* Returns all the keys from the hash. The number of keys is placed
|
||||
* into the value pointed to by num_keys. If key_sizes is not NULL,
|
||||
* it will be set to an array of key sizes. If fast is zero, copies
|
||||
* of the keys are returned. Otherwise, pointers to the real keys
|
||||
* will be returned.
|
||||
*/
|
||||
extern void **cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes,
|
||||
int fast);
|
||||
|
||||
/* Initializes a loop over all the key/value pairs in the hash. It
|
||||
* returns the first key/value pair (see cfuhash_next_data()). 1 is
|
||||
* returned if there are any entries in the hash. 0 is returned
|
||||
* otherwise.
|
||||
*/
|
||||
extern int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data,
|
||||
size_t *data_size);
|
||||
/* Initializes a loop over all the key/value pairs in the hash. It
|
||||
* returns the first key/value pair (see cfuhash_next_data()). 1 is
|
||||
* returned if there are any entries in the hash. 0 is returned
|
||||
* otherwise.
|
||||
*/
|
||||
extern int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data,
|
||||
size_t *data_size);
|
||||
|
||||
/* Gets the next key/value pair from the hash. You must initialize
|
||||
* the loop using cfuhash_each_data() before calling this function.
|
||||
* If a entry is left to return, 1 is returned from the function. 0
|
||||
* is returned if there are no more entries in the hash.
|
||||
*/
|
||||
extern int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data,
|
||||
size_t *data_size);
|
||||
/* Gets the next key/value pair from the hash. You must initialize
|
||||
* the loop using cfuhash_each_data() before calling this function.
|
||||
* If a entry is left to return, 1 is returned from the function. 0
|
||||
* is returned if there are no more entries in the hash.
|
||||
*/
|
||||
extern int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data,
|
||||
size_t *data_size);
|
||||
|
||||
/* Iterates over the key/value pairs in the hash, passing each one
|
||||
* to r_fn, and removes all entries for which r_fn returns true.
|
||||
* If ff is not NULL, it is the passed the data to be freed. arg
|
||||
* is passed to r_fn.
|
||||
*/
|
||||
extern size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn,
|
||||
cfuhash_free_fn_t ff, void *arg);
|
||||
/* Iterates over the key/value pairs in the hash, passing each one
|
||||
* to r_fn, and removes all entries for which r_fn returns true.
|
||||
* If ff is not NULL, it is the passed the data to be freed. arg
|
||||
* is passed to r_fn.
|
||||
*/
|
||||
extern size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn,
|
||||
cfuhash_free_fn_t ff, void *arg);
|
||||
|
||||
/* Iterates over the key/value pairs in the hash, passing each one
|
||||
* to fe_fn, along with arg. This locks the hash, so do not call
|
||||
* any operations on the hash from within fe_fn unless you really
|
||||
* know what you're doing. A non-zero return value from fe_fn()
|
||||
* stops the iteration.
|
||||
*/
|
||||
extern size_t cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg);
|
||||
/* Iterates over the key/value pairs in the hash, passing each one
|
||||
* to fe_fn, along with arg. This locks the hash, so do not call
|
||||
* any operations on the hash from within fe_fn unless you really
|
||||
* know what you're doing. A non-zero return value from fe_fn()
|
||||
* stops the iteration.
|
||||
*/
|
||||
extern size_t cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg);
|
||||
|
||||
/* Frees all resources allocated by the hash. If ff is not NULL, it
|
||||
* is called for each hash entry with the value of the entry passed as
|
||||
* its only argument. If ff is not NULL, it overrides any function
|
||||
* set previously with cfuhash_set_free_function().
|
||||
*/
|
||||
extern int cfuhash_destroy(cfuhash_table_t *ht);
|
||||
/* Frees all resources allocated by the hash. If ff is not NULL, it
|
||||
* is called for each hash entry with the value of the entry passed as
|
||||
* its only argument. If ff is not NULL, it overrides any function
|
||||
* set previously with cfuhash_set_free_function().
|
||||
*/
|
||||
extern int cfuhash_destroy(cfuhash_table_t *ht);
|
||||
|
||||
extern int cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff);
|
||||
extern int cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff);
|
||||
|
||||
/* Rebuild the hash to better accomodate the number of entries. See
|
||||
* cfuhash_set_thresholds().
|
||||
*/
|
||||
extern int cfuhash_rehash(cfuhash_table_t *ht);
|
||||
/* Rebuild the hash to better accomodate the number of entries. See
|
||||
* cfuhash_set_thresholds().
|
||||
*/
|
||||
extern int cfuhash_rehash(cfuhash_table_t *ht);
|
||||
|
||||
/* Returns the number entries in the hash. */
|
||||
extern size_t cfuhash_num_entries(cfuhash_table_t *ht);
|
||||
/* Returns the number entries in the hash. */
|
||||
extern size_t cfuhash_num_entries(cfuhash_table_t *ht);
|
||||
|
||||
/* Returns the number of buckets allocated for the hash. */
|
||||
extern size_t cfuhash_num_buckets(cfuhash_table_t *ht);
|
||||
/* Returns the number of buckets allocated for the hash. */
|
||||
extern size_t cfuhash_num_buckets(cfuhash_table_t *ht);
|
||||
|
||||
/* Returns the number of buckets actually used out of the total number
|
||||
* allocated for the hash.
|
||||
*/
|
||||
extern size_t cfuhash_num_buckets_used(cfuhash_table_t *ht);
|
||||
/* Returns the number of buckets actually used out of the total number
|
||||
* allocated for the hash.
|
||||
*/
|
||||
extern size_t cfuhash_num_buckets_used(cfuhash_table_t *ht);
|
||||
|
||||
/* Assumes all the keys and values are null-terminated strings and
|
||||
* returns a bencoded string representing the hash (see
|
||||
* http://www.bittorrent.com/protocol.html)
|
||||
*/
|
||||
extern char * cfuhash_bencode_strings(cfuhash_table_t *ht);
|
||||
/* Assumes all the keys and values are null-terminated strings and
|
||||
* returns a bencoded string representing the hash (see
|
||||
* http://www.bittorrent.com/protocol.html)
|
||||
*/
|
||||
extern char * cfuhash_bencode_strings(cfuhash_table_t *ht);
|
||||
|
||||
/* Locks the hash. Use this with the each and next functions for
|
||||
* concurrency control. Note that the hash is locked automatically
|
||||
* when doing inserts and deletes, so if you lock the hash and then
|
||||
* try to insert something into it, you may get into a deadlock,
|
||||
* depending on your system defaults for how mutexes work.
|
||||
*/
|
||||
extern int cfuhash_lock(cfuhash_table_t *ht);
|
||||
/* Locks the hash. Use this with the each and next functions for
|
||||
* concurrency control. Note that the hash is locked automatically
|
||||
* when doing inserts and deletes, so if you lock the hash and then
|
||||
* try to insert something into it, you may get into a deadlock,
|
||||
* depending on your system defaults for how mutexes work.
|
||||
*/
|
||||
extern int cfuhash_lock(cfuhash_table_t *ht);
|
||||
|
||||
/* Unlocks the hash. Use this with the each an next functions for
|
||||
* concurrency control. The caveat for cfuhash_lcok() also applies to
|
||||
* this function.
|
||||
*/
|
||||
extern int cfuhash_unlock(cfuhash_table_t *ht);
|
||||
/* Unlocks the hash. Use this with the each an next functions for
|
||||
* concurrency control. The caveat for cfuhash_lcok() also applies to
|
||||
* this function.
|
||||
*/
|
||||
extern int cfuhash_unlock(cfuhash_table_t *ht);
|
||||
|
||||
/* Pretty print the hash's key/value pairs to the stream fp. It is
|
||||
* assumed that all the keys and values are null-terminated strings.
|
||||
*/
|
||||
extern int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp);
|
||||
/* Pretty print the hash's key/value pairs to the stream fp. It is
|
||||
* assumed that all the keys and values are null-terminated strings.
|
||||
*/
|
||||
extern int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp);
|
||||
|
||||
/* These are like the _data versions of these functions, with the
|
||||
* following exceptions:
|
||||
* 1) They assume that the key provided is a null-terminated string.
|
||||
* 2) They don't worry about the size of the data.
|
||||
* 3) Returned keys or values are the return value of the function.
|
||||
*/
|
||||
extern void * cfuhash_get(cfuhash_table_t *ht, const char *key);
|
||||
extern int cfuhash_exists(cfuhash_table_t *ht, const char *key);
|
||||
extern void * cfuhash_put(cfuhash_table_t *ht, const char *key, void *data);
|
||||
extern void * cfuhash_delete(cfuhash_table_t *ht, const char *key);
|
||||
extern int cfuhash_each(cfuhash_table_t *ht, char **key, void **data);
|
||||
extern int cfuhash_next(cfuhash_table_t *ht, char **key, void **data);
|
||||
extern void **cfuhash_keys(cfuhash_table_t *ht, size_t *num_keys, int fast);
|
||||
/* These are like the _data versions of these functions, with the
|
||||
* following exceptions:
|
||||
* 1) They assume that the key provided is a null-terminated string.
|
||||
* 2) They don't worry about the size of the data.
|
||||
* 3) Returned keys or values are the return value of the function.
|
||||
*/
|
||||
extern void * cfuhash_get(cfuhash_table_t *ht, const char *key);
|
||||
extern int cfuhash_exists(cfuhash_table_t *ht, const char *key);
|
||||
extern void * cfuhash_put(cfuhash_table_t *ht, const char *key, void *data);
|
||||
extern void * cfuhash_delete(cfuhash_table_t *ht, const char *key);
|
||||
extern int cfuhash_each(cfuhash_table_t *ht, char **key, void **data);
|
||||
extern int cfuhash_next(cfuhash_table_t *ht, char **key, void **data);
|
||||
extern void **cfuhash_keys(cfuhash_table_t *ht, size_t *num_keys, int fast);
|
||||
|
||||
|
||||
/* hash table flags */
|
||||
|
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-07-02 22:25:39
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfulist.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
237
src/cfulist.h
237
src/cfulist.h
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-07-02 22:25:10
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfulist.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFU_LIST_
|
||||
#define _CFU_LIST_
|
||||
|
||||
@ -46,113 +43,113 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
/* The list itself. */
|
||||
struct cfulist;
|
||||
typedef struct cfulist cfulist_t;
|
||||
/* The list itself. */
|
||||
struct cfulist;
|
||||
typedef struct cfulist cfulist_t;
|
||||
|
||||
/* Function called for each element in the list when passed to
|
||||
* cfulist_foreach(). A non-zero return value means to stop
|
||||
* iteration.
|
||||
*/
|
||||
typedef int (*cfulist_foreach_fn_t)(void *data, size_t data_size, void *arg);
|
||||
/* Function called for each element in the list when passed to
|
||||
* cfulist_foreach(). A non-zero return value means to stop
|
||||
* iteration.
|
||||
*/
|
||||
typedef int (*cfulist_foreach_fn_t)(void *data, size_t data_size, void *arg);
|
||||
|
||||
/* Function called for each element in the list when passed to
|
||||
* cfulist_map(). The return value is used to build a new
|
||||
* list.
|
||||
*/
|
||||
typedef void * (*cfulist_map_fn_t)(void *data, size_t data_size, void *arg,
|
||||
size_t *new_data_size);
|
||||
/* Function called for each element in the list when passed to
|
||||
* cfulist_map(). The return value is used to build a new
|
||||
* list.
|
||||
*/
|
||||
typedef void * (*cfulist_map_fn_t)(void *data, size_t data_size, void *arg,
|
||||
size_t *new_data_size);
|
||||
|
||||
/* Function called to free the data in an element. */
|
||||
typedef void (*cfulist_free_fn_t)(void *data);
|
||||
/* Function called to free the data in an element. */
|
||||
typedef void (*cfulist_free_fn_t)(void *data);
|
||||
|
||||
/* Returns a new list. */
|
||||
extern cfulist_t * cfulist_new();
|
||||
/* Returns a new list. */
|
||||
extern cfulist_t * cfulist_new();
|
||||
|
||||
/* Same as cfulist_new(), but set a function to be called on each
|
||||
* element when the list is destroyed.
|
||||
*/
|
||||
extern cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn);
|
||||
/* Same as cfulist_new(), but set a function to be called on each
|
||||
* element when the list is destroyed.
|
||||
*/
|
||||
extern cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn);
|
||||
|
||||
/* Returns the number of entries in the list. */
|
||||
extern size_t cfulist_num_entries(cfulist_t *list);
|
||||
/* Returns the number of entries in the list. */
|
||||
extern size_t cfulist_num_entries(cfulist_t *list);
|
||||
|
||||
/* Manipulating list entries */
|
||||
/* Manipulating list entries */
|
||||
|
||||
/* Push a value onto the end of the list. */
|
||||
extern int cfulist_push_data(cfulist_t *list, void *data, size_t data_size);
|
||||
/* Push a value onto the end of the list. */
|
||||
extern int cfulist_push_data(cfulist_t *list, void *data, size_t data_size);
|
||||
|
||||
/* Pop a value from the end of the list. */
|
||||
extern int cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
/* Pop a value from the end of the list. */
|
||||
extern int cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Add a value at the beginning of the list. */
|
||||
extern int cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size);
|
||||
/* Add a value at the beginning of the list. */
|
||||
extern int cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size);
|
||||
|
||||
/* Shift a value off the beginning of the list. */
|
||||
extern int cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
/* Shift a value off the beginning of the list. */
|
||||
extern int cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Add a value at the end of the queue (equivalent to push) */
|
||||
extern int cfulist_enqueue_data(cfulist_t *list, void *data, size_t data_size);
|
||||
/* Add a value at the end of the queue (equivalent to push) */
|
||||
extern int cfulist_enqueue_data(cfulist_t *list, void *data, size_t data_size);
|
||||
|
||||
/* Remove the value at the beginning of the list (equivalent to shift). */
|
||||
extern int cfulist_dequeue_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
/* Remove the value at the beginning of the list (equivalent to shift). */
|
||||
extern int cfulist_dequeue_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Return the last entry from the list (without removing it from
|
||||
* the list).
|
||||
*/
|
||||
extern int cfulist_first_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
/* Return the last entry from the list (without removing it from
|
||||
* the list).
|
||||
*/
|
||||
extern int cfulist_first_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Return the last entry from the list (without removing it from
|
||||
* the list).
|
||||
*/
|
||||
extern int cfulist_last_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
/* Return the last entry from the list (without removing it from
|
||||
* the list).
|
||||
*/
|
||||
extern int cfulist_last_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Return the nth entry from the list (without removing it from
|
||||
* the list). n starts at zero.
|
||||
*/
|
||||
extern int cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n);
|
||||
/* Return the nth entry from the list (without removing it from
|
||||
* the list). n starts at zero.
|
||||
*/
|
||||
extern int cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n);
|
||||
|
||||
extern void cfulist_reset_each(cfulist_t *list);
|
||||
extern int cfulist_each_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
extern int cfulist_next_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
extern void cfulist_reset_each(cfulist_t *list);
|
||||
extern int cfulist_each_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
extern int cfulist_next_data(cfulist_t *list, void **data, size_t *data_size);
|
||||
|
||||
/* Calls fe_fn() for each element in the list. Also passes arg on
|
||||
* each call. If fe_fn() returns a non-zero value, the iteration
|
||||
* over the elements stops.
|
||||
*/
|
||||
extern size_t cfulist_foreach(cfulist_t *list, cfulist_foreach_fn_t fe_fn, void *arg);
|
||||
/* Calls fe_fn() for each element in the list. Also passes arg on
|
||||
* each call. If fe_fn() returns a non-zero value, the iteration
|
||||
* over the elements stops.
|
||||
*/
|
||||
extern size_t cfulist_foreach(cfulist_t *list, cfulist_foreach_fn_t fe_fn, void *arg);
|
||||
|
||||
/* Creates a new list from the list passed in. Calls map_fn() on
|
||||
* each element in the list. The return value is placed in the
|
||||
* corresponding position in the new list.
|
||||
*/
|
||||
extern cfulist_t *cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg);
|
||||
/* Creates a new list from the list passed in. Calls map_fn() on
|
||||
* each element in the list. The return value is placed in the
|
||||
* corresponding position in the new list.
|
||||
*/
|
||||
extern cfulist_t *cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg);
|
||||
|
||||
/* Free all resources used by the list. */
|
||||
extern void cfulist_destroy(cfulist_t *list);
|
||||
extern void cfulist_destroy_with_free_fn(cfulist_t *list, cfulist_free_fn_t free_fn);
|
||||
/* Free all resources used by the list. */
|
||||
extern void cfulist_destroy(cfulist_t *list);
|
||||
extern void cfulist_destroy_with_free_fn(cfulist_t *list, cfulist_free_fn_t free_fn);
|
||||
|
||||
/* When you don't care about the size of the data */
|
||||
/* When you don't care about the size of the data */
|
||||
|
||||
extern int cfulist_push(cfulist_t *list, void *data);
|
||||
extern void * cfulist_pop(cfulist_t *list);
|
||||
extern int cfulist_unshift(cfulist_t *list, void *data);
|
||||
extern void * cfulist_shift(cfulist_t *list);
|
||||
extern int cfulist_enqueue(cfulist_t *list, void *data);
|
||||
extern void *cfulist_dequeue(cfulist_t *list);
|
||||
extern int cfulist_push(cfulist_t *list, void *data);
|
||||
extern void * cfulist_pop(cfulist_t *list);
|
||||
extern int cfulist_unshift(cfulist_t *list, void *data);
|
||||
extern void * cfulist_shift(cfulist_t *list);
|
||||
extern int cfulist_enqueue(cfulist_t *list, void *data);
|
||||
extern void *cfulist_dequeue(cfulist_t *list);
|
||||
|
||||
/* Strings -- assume data is a null-terminated string -- size is
|
||||
* calculated by strlen(data) + 1
|
||||
*/
|
||||
/* Strings -- assume data is a null-terminated string -- size is
|
||||
* calculated by strlen(data) + 1
|
||||
*/
|
||||
|
||||
extern int cfulist_push_string(cfulist_t *list, char *data);
|
||||
extern char * cfulist_pop_string(cfulist_t *list);
|
||||
extern int cfulist_unshift_string(cfulist_t *list, char *data);
|
||||
extern char * cfulist_shift_string(cfulist_t *list);
|
||||
extern int cfulist_enqueue_string(cfulist_t *list, char *data);
|
||||
extern char *cfulist_dequeue_string(cfulist_t *list);
|
||||
extern int cfulist_push_string(cfulist_t *list, char *data);
|
||||
extern char * cfulist_pop_string(cfulist_t *list);
|
||||
extern int cfulist_unshift_string(cfulist_t *list, char *data);
|
||||
extern char * cfulist_shift_string(cfulist_t *list);
|
||||
extern int cfulist_enqueue_string(cfulist_t *list, char *data);
|
||||
extern char *cfulist_dequeue_string(cfulist_t *list);
|
||||
|
||||
extern char *cfulist_join(cfulist_t *list, const char *delimiter);
|
||||
extern char *cfulist_join(cfulist_t *list, const char *delimiter);
|
||||
|
||||
CFU_END_DECLS
|
||||
|
||||
|
38
src/cfuopt.c
38
src/cfuopt.c
@ -1,6 +1,38 @@
|
||||
/* Creation date: 2005-09-04 12:57:25
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuopt.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfu.h"
|
||||
|
38
src/cfuopt.h
38
src/cfuopt.h
@ -1,6 +1,38 @@
|
||||
/* Creation date: 2005-09-04 12:54:41
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuopt.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include <cfu.h>
|
||||
|
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-26 19:59:10
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfustring.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfu.h"
|
||||
|
||||
#include "cfustring.h"
|
||||
|
175
src/cfustring.h
175
src/cfustring.h
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-26 19:56:34
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfustring.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFU_STRING_H_
|
||||
#define _CFU_STRING_H_
|
||||
|
||||
@ -47,74 +44,74 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
struct cfustring;
|
||||
typedef struct cfustring cfustring_t;
|
||||
struct cfustring;
|
||||
typedef struct cfustring cfustring_t;
|
||||
|
||||
/* Returns a new String. */
|
||||
extern cfustring_t * cfustring_new();
|
||||
/* Returns a new String. */
|
||||
extern cfustring_t * cfustring_new();
|
||||
|
||||
/* Returns a new String, but preallocates a buffer of the given size. */
|
||||
extern cfustring_t * cfustring_new_with_initial_size(size_t initial_size);
|
||||
/* Returns a new String, but preallocates a buffer of the given size. */
|
||||
extern cfustring_t * cfustring_new_with_initial_size(size_t initial_size);
|
||||
|
||||
/* Returns a new String initalized with the given string. */
|
||||
extern cfustring_t * cfustring_new_from_string(const char *string);
|
||||
/* Returns a new String initalized with the given string. */
|
||||
extern cfustring_t * cfustring_new_from_string(const char *string);
|
||||
|
||||
/* Overwrite anything currently in cfu_str with string. */
|
||||
extern int cfustring_dup(cfustring_t *cfu_str, const char *string);
|
||||
/* Overwrite anything currently in cfu_str with string. */
|
||||
extern int cfustring_dup(cfustring_t *cfu_str, const char *string);
|
||||
|
||||
/* Truncate the string. */
|
||||
extern int cfustring_clear(cfustring_t *cfu_str);
|
||||
/* Truncate the string. */
|
||||
extern int cfustring_clear(cfustring_t *cfu_str);
|
||||
|
||||
/* Append str to the end of the buffer in cfu_str. */
|
||||
extern int cfustring_append(cfustring_t *cfu_str, const char *str);
|
||||
/* Append str to the end of the buffer in cfu_str. */
|
||||
extern int cfustring_append(cfustring_t *cfu_str, const char *str);
|
||||
|
||||
/* Get the buffer used to hold the string. Do not free() it, as it is
|
||||
* used directly by cfustring and will be destroyed when
|
||||
* cfustring_destroy() is called.
|
||||
*/
|
||||
extern char * cfustring_get_buffer(cfustring_t *cfu_str);
|
||||
/* Get the buffer used to hold the string. Do not free() it, as it is
|
||||
* used directly by cfustring and will be destroyed when
|
||||
* cfustring_destroy() is called.
|
||||
*/
|
||||
extern char * cfustring_get_buffer(cfustring_t *cfu_str);
|
||||
|
||||
/* Same as cfustring_get_buffer(), except return a copy of the string.
|
||||
* Caller is responsible for deallocating the buffer with free().
|
||||
*/
|
||||
extern char * cfustring_get_buffer_copy(cfustring_t *cfu_str);
|
||||
/* Same as cfustring_get_buffer(), except return a copy of the string.
|
||||
* Caller is responsible for deallocating the buffer with free().
|
||||
*/
|
||||
extern char * cfustring_get_buffer_copy(cfustring_t *cfu_str);
|
||||
|
||||
/* Split cfu_str on one or more delimiting strings, e.g.,
|
||||
* cfustring_split(cfu_str, 2, 0, "\r\n", "\n"). Use a limit > 0 if
|
||||
* you want to only get back a certain number of strings and ignore
|
||||
* any extra delimiters.
|
||||
*/
|
||||
extern cfustring_t ** cfustring_split(cfustring_t *cfu_str, size_t *num_strings,
|
||||
size_t limit, ...);
|
||||
/* Split cfu_str on one or more delimiting strings, e.g.,
|
||||
* cfustring_split(cfu_str, 2, 0, "\r\n", "\n"). Use a limit > 0 if
|
||||
* you want to only get back a certain number of strings and ignore
|
||||
* any extra delimiters.
|
||||
*/
|
||||
extern cfustring_t ** cfustring_split(cfustring_t *cfu_str, size_t *num_strings,
|
||||
size_t limit, ...);
|
||||
|
||||
/* Same as cfustring_split(), except return an array of C-strings.
|
||||
* Caller is responsible for deallocating the buffers.
|
||||
*/
|
||||
extern char ** cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings,
|
||||
size_t limit, ...);
|
||||
/* Same as cfustring_split(), except return an array of C-strings.
|
||||
* Caller is responsible for deallocating the buffers.
|
||||
*/
|
||||
extern char ** cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings,
|
||||
size_t limit, ...);
|
||||
|
||||
/* Free all resources allocated by cfu_str. */
|
||||
extern int cfustring_destroy(cfustring_t *cfu_str);
|
||||
/* Free all resources allocated by cfu_str. */
|
||||
extern int cfustring_destroy(cfustring_t *cfu_str);
|
||||
|
||||
/* Duplicate the C string str. Caller must free with free(). */
|
||||
extern char * cfustring_dup_c_str(const char *str);
|
||||
/* Duplicate the C string str. Caller must free with free(). */
|
||||
extern char * cfustring_dup_c_str(const char *str);
|
||||
|
||||
/* Same as cfustring_dup_c_str(), but only copy at most n chars */
|
||||
extern char * cfustring_dup_c_str_n(const char *str, size_t n);
|
||||
/* Same as cfustring_dup_c_str(), but only copy at most n chars */
|
||||
extern char * cfustring_dup_c_str_n(const char *str, size_t n);
|
||||
|
||||
/* Like sprintf(), but writes to a self-extending string. */
|
||||
extern size_t cfustring_sprintf(cfustring_t *cfu_str, const char *fmt, ...);
|
||||
/* Like sprintf(), but writes to a self-extending string. */
|
||||
extern size_t cfustring_sprintf(cfustring_t *cfu_str, const char *fmt, ...);
|
||||
|
||||
/* Like vsprintf(), but writes to a self-extending string. */
|
||||
extern size_t cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt, va_list ap);
|
||||
/* Like vsprintf(), but writes to a self-extending string. */
|
||||
extern size_t cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt, va_list ap);
|
||||
|
||||
/* Similar to sprintf(), but allocates a C string of the
|
||||
* appropriate size for you and returns it.
|
||||
*/
|
||||
extern char * cfustring_sprintf_c_str(const char *fmt, ...);
|
||||
/* Similar to sprintf(), but allocates a C string of the
|
||||
* appropriate size for you and returns it.
|
||||
*/
|
||||
extern char * cfustring_sprintf_c_str(const char *fmt, ...);
|
||||
|
||||
/* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */
|
||||
extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...);
|
||||
/* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */
|
||||
extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...);
|
||||
|
||||
CFU_END_DECLS
|
||||
|
||||
|
@ -1,8 +1,38 @@
|
||||
/* Creation date: 2005-07-26 08:20:59
|
||||
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
|
||||
/*
|
||||
* cfuthread_queue.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfuthread_queue.h"
|
||||
|
@ -1,44 +1,40 @@
|
||||
/* Creation date: 2005-07-26 08:19:33
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfuthread_queue.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFUTHREAD_QUEUE_H
|
||||
#define _CFUTHREAD_QUEUE_H
|
||||
|
||||
@ -46,49 +42,49 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
/* cfuthread_queue provides a way to serialize requests for a
|
||||
* resource where you want the resource to be accessed from a
|
||||
* single thread only. For instance, for a database connection
|
||||
* where making calls in separate threads does not work properly,
|
||||
* you can use cfuthread_queue. cfuthread_queue_new() creates a
|
||||
* new thread that waits for something to be added to the queue.
|
||||
* Once something is added, the thread will process the data by
|
||||
* calling the function you pass as an argument to the
|
||||
* cfuthread_queue_new() function.
|
||||
*/
|
||||
/* cfuthread_queue provides a way to serialize requests for a
|
||||
* resource where you want the resource to be accessed from a
|
||||
* single thread only. For instance, for a database connection
|
||||
* where making calls in separate threads does not work properly,
|
||||
* you can use cfuthread_queue. cfuthread_queue_new() creates a
|
||||
* new thread that waits for something to be added to the queue.
|
||||
* Once something is added, the thread will process the data by
|
||||
* calling the function you pass as an argument to the
|
||||
* cfuthread_queue_new() function.
|
||||
*/
|
||||
|
||||
struct cfuthread_queue;
|
||||
typedef struct cfuthread_queue cfuthread_queue_t;
|
||||
struct cfuthread_queue;
|
||||
typedef struct cfuthread_queue cfuthread_queue_t;
|
||||
|
||||
typedef void * (*cfuthread_queue_fn_t)(void *arg);
|
||||
typedef void (*cfuthread_queue_init_t)(void *arg);
|
||||
typedef void (*cfuthread_queue_cleanup_t)(void *arg);
|
||||
typedef void * (*cfuthread_queue_fn_t)(void *arg);
|
||||
typedef void (*cfuthread_queue_init_t)(void *arg);
|
||||
typedef void (*cfuthread_queue_cleanup_t)(void *arg);
|
||||
|
||||
/* Creates a new thread queue structure that will run the given
|
||||
* function when a request is received.
|
||||
*/
|
||||
extern cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn);
|
||||
/* Creates a new thread queue structure that will run the given
|
||||
* function when a request is received.
|
||||
*/
|
||||
extern cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn);
|
||||
|
||||
/* Same as cfuthread_queue_new(), but with an initialization
|
||||
* function that gets called with the argument init_arg when the
|
||||
* thread is created, and a cleanup function that gets called with
|
||||
* the argument cleanup_arg when the thread exits, e.g., when
|
||||
* cfuthread_queue_destroy() is called.
|
||||
*/
|
||||
extern cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn,
|
||||
cfuthread_queue_init_t init_fn, void *init_arg, cfuthread_queue_cleanup_t cleanup_fn,
|
||||
void *cleanup_arg);
|
||||
/* Same as cfuthread_queue_new(), but with an initialization
|
||||
* function that gets called with the argument init_arg when the
|
||||
* thread is created, and a cleanup function that gets called with
|
||||
* the argument cleanup_arg when the thread exits, e.g., when
|
||||
* cfuthread_queue_destroy() is called.
|
||||
*/
|
||||
extern cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn,
|
||||
cfuthread_queue_init_t init_fn, void *init_arg, cfuthread_queue_cleanup_t cleanup_fn,
|
||||
void *cleanup_arg);
|
||||
|
||||
/* Add a request to the queue. data will get passed to the
|
||||
* function fn given to cfuthread_queue_new when it reaches the
|
||||
* front of the queue.
|
||||
*/
|
||||
extern void * cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data);
|
||||
/* Add a request to the queue. data will get passed to the
|
||||
* function fn given to cfuthread_queue_new when it reaches the
|
||||
* front of the queue.
|
||||
*/
|
||||
extern void * cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data);
|
||||
|
||||
/* Free up resources used by the queue, in addition to canceling
|
||||
* the thread.
|
||||
*/
|
||||
extern void cfuthread_queue_destroy(cfuthread_queue_t *);
|
||||
/* Free up resources used by the queue, in addition to canceling
|
||||
* the thread.
|
||||
*/
|
||||
extern void cfuthread_queue_destroy(cfuthread_queue_t *);
|
||||
|
||||
CFU_END_DECLS
|
||||
|
||||
|
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-26 18:11:40
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfutime.c - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include "cfu.h"
|
||||
#include "cfutime.h"
|
||||
|
||||
|
@ -1,43 +1,40 @@
|
||||
/* Creation date: 2005-06-26 18:09:46
|
||||
* Authors: Don
|
||||
* Change log:
|
||||
/*
|
||||
* cfutime.h - This file is part of the libcfu library
|
||||
*
|
||||
* Copyright (c) 2005 Don Owens. All rights reserved.
|
||||
*
|
||||
* This code is released under the BSD license:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * 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.
|
||||
*
|
||||
* * Neither the name of the author nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Don Owens
|
||||
All rights reserved.
|
||||
|
||||
This code is released under the BSD license:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#ifndef _CFU_TIME_H_
|
||||
#define _CFU_TIME_H_
|
||||
|
||||
@ -45,23 +42,23 @@
|
||||
|
||||
CFU_BEGIN_DECLS
|
||||
|
||||
struct cfutime;
|
||||
typedef struct cfutime cfutime_t;
|
||||
struct cfutime;
|
||||
typedef struct cfutime cfutime_t;
|
||||
|
||||
/* Return a new cfutime structure. */
|
||||
extern cfutime_t *cfutime_new();
|
||||
/* Return a new cfutime structure. */
|
||||
extern cfutime_t *cfutime_new();
|
||||
|
||||
/* Start the timer. */
|
||||
extern void cfutime_begin(cfutime_t *time);
|
||||
/* Start the timer. */
|
||||
extern void cfutime_begin(cfutime_t *time);
|
||||
|
||||
/* Stop the timer. */
|
||||
extern void cfutime_end(cfutime_t *time);
|
||||
/* Stop the timer. */
|
||||
extern void cfutime_end(cfutime_t *time);
|
||||
|
||||
/* Return the number of seconds elapsed as a double. */
|
||||
extern double cfutime_elapsed(cfutime_t *time);
|
||||
/* Return the number of seconds elapsed as a double. */
|
||||
extern double cfutime_elapsed(cfutime_t *time);
|
||||
|
||||
/* Deallocate resources allocated for time. */
|
||||
extern void cfutime_free(cfutime_t *time);
|
||||
/* Deallocate resources allocated for time. */
|
||||
extern void cfutime_free(cfutime_t *time);
|
||||
|
||||
CFU_END_DECLS
|
||||
|
||||
|
Reference in New Issue
Block a user