------------------------------------------------------------ revno: 5161 author: Stefan Götz <stefan.goetz@xxxxxxxxxxxxxxxxx> committer: Diego Biurrun <diego@xxxxxxxxxx> branch nick: fw-cache-port-cleanup timestamp: Mon 2010-11-15 22:31:26 +0100 message: Removed _inline header files and moved the inline functions into their regular counterparts. This makes 'make checkheaders' succeed again. removed: firewall/file_buffer_inline.h firewall/line_parser_inline.h modified: firewall/file_buffer.h firewall/line_parser.h firewall/port_bindings.c -- lp:hipl https://code.launchpad.net/~hipl-core/hipl/trunk Your team HIPL core team is subscribed to branch lp:hipl. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'firewall/file_buffer.h' --- firewall/file_buffer.h 2010-11-12 17:49:42 +0000 +++ firewall/file_buffer.h 2010-11-15 21:31:26 +0000 @@ -31,6 +31,9 @@ #ifndef HIP_FIREWALL_FILE_BUFFER_H #define HIP_FIREWALL_FILE_BUFFER_H +#include <sys/types.h> +#include <stddef.h> + #include "mem_area.h" struct hip_file_buffer; @@ -41,6 +44,53 @@ static inline const struct hip_mem_area *hip_fb_get_mem_area(const struct hip_file_buffer *const fb); int hip_fb_reload(struct hip_file_buffer *const fb); -#include "firewall/file_buffer_inline.h" +/** + * A file buffer object represents an open file and its associated memory + * buffer. + */ +struct hip_file_buffer { + /** + * The memory area holding the file contents. + * Its start field points to the first byte of file data and the beginning + * of the allocated memory buffer. + * Its end field points to the last byte of file data + 1. + */ + struct hip_mem_area ma; + /* + * The number of bytes in the allocated buffer that ma.start points to. + * buffer_size is equal to or greater than (ma.end - ma.start). + */ + size_t buffer_size; + /* + * The file descriptor for the file backing the buffer. + */ + int fd; +}; + +/** + * Retrieve the memory area in which the file contents are stored. + * + * There is a 1:1 relationship between the passed in fb object and the returned + * pointer. + * That is, calling this function on the same fb object will always return the + * same struct hip_mem_area pointer. + * Thus, you may assume that the returned struct hip_mem_area pointer has the + * same life time as its associated struct hip_file_buffer object. + * However, hip_fb_reload() may change the start and end address in the + * returned struct hip_mem_area object! + * + * @param fb the file buffer object holding the memory area to retrieve. + * @return a pointer to the struct hip_mem_area object associated with the + * given file buffer object. + * If the passed in file buffer pointer is invalid, this function returns + * NULL. + */ +static inline const struct hip_mem_area *hip_fb_get_mem_area(const struct hip_file_buffer *const fb) +{ + if (fb) { + return &fb->ma; + } + return NULL; +} #endif /* HIP_FIREWALL_FILE_BUFFER_H */ === removed file 'firewall/file_buffer_inline.h' --- firewall/file_buffer_inline.h 2010-11-12 17:49:42 +0000 +++ firewall/file_buffer_inline.h 1970-01-01 00:00:00 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * @file - * @author Stefan Goetz <stefan.goetz@xxxxxxxxxxxxxxxxx> - */ - -#ifndef HIP_FIREWALL_FILE_BUFFER_INLINE_H -#define HIP_FIREWALL_FILE_BUFFER_INLINE_H - -/* On the one hand, the contents of this file are part of the public interface - * and thus only their declaration should go into the public header file. - * On the other hand, these functions should be inlineable so their definitions - * have to appear in a header file. - * To achieve inlineability and still hide the implementation, we use this - * secondary header file that is not part of the public interface. */ -#ifndef HIP_FIREWALL_FILE_BUFFER_H -#error This file must not be included directly because it contains implementation details. It may only be included by file_buffer.h. -#endif - -#include <sys/types.h> -#include <stddef.h> - -#include "mem_area.h" - -/** - * A file buffer object represents an open file and its associated memory - * buffer. - */ -struct hip_file_buffer { - /** - * The memory area holding the file contents. - * Its start field points to the first byte of file data and the beginning - * of the allocated memory buffer. - * Its end field points to the last byte of file data + 1. - */ - struct hip_mem_area ma; - /* - * The number of bytes in the allocated buffer that ma.start points to. - * buffer_size is equal to or greater than (ma.end - ma.start). - */ - size_t buffer_size; - /* - * The file descriptor for the file backing the buffer. - */ - int fd; -}; - -/** - * Retrieve the memory area in which the file contents are stored. - * - * There is a 1:1 relationship between the passed in fb object and the returned - * pointer. - * That is, calling this function on the same fb object will always return the - * same struct hip_mem_area pointer. - * Thus, you may assume that the returned struct hip_mem_area pointer has the - * same life time as its associated struct hip_file_buffer object. - * However, hip_fb_reload() may change the start and end address in the - * returned struct hip_mem_area object! - * - * @param fb the file buffer object holding the memory area to retrieve. - * @return a pointer to the struct hip_mem_area object associated with the - * given file buffer object. - * If the passed in file buffer pointer is invalid, this function returns - * NULL. - */ -static inline const struct hip_mem_area *hip_fb_get_mem_area(const struct hip_file_buffer *const fb) -{ - if (fb) { - return &fb->ma; - } - return NULL; -} - -#endif /* HIP_FIREWALL_FILE_BUFFER_INLINE_H */ === modified file 'firewall/line_parser.h' --- firewall/line_parser.h 2010-11-12 17:49:42 +0000 +++ firewall/line_parser.h 2010-11-15 21:31:26 +0000 @@ -31,6 +31,8 @@ #ifndef HIP_FIREWALL_LINE_PARSER_H #define HIP_FIREWALL_LINE_PARSER_H +#include <string.h> + #include "mem_area.h" struct hip_line_parser; @@ -41,6 +43,88 @@ static inline char *hip_lp_first(struct hip_line_parser *const lp); static inline char *hip_lp_next(struct hip_line_parser *const lp); -#include "firewall/line_parser_inline.h" +/** + * Represents the parsing state on a memory area object. + */ +struct hip_line_parser { + /** + * The memory area this parser operates on. + */ + const struct hip_mem_area *ma; + /** + * The current parsing position. + * If NULL, hip_lp_first() needs to be called. + * If != NULL, points to the start of line in the memory buffer. + */ + char *cur; +}; + +/** + * Start a new parsing pass with a line parser and return the first line in the + * buffer. + * The buffer is not modified and the line is terminated by a newline + * character (not a null character). + * + * A parsing pass consists of starting it via hip_lp_first() and iterating over + * the lines in the file via hip_lp_next() until it returns NULL. + * + * @param lp the line parser to use. + * @return a pointer to the first line in the file or NULL if no line is + * available. + */ +static inline char *hip_lp_first(struct hip_line_parser *const lp) +{ + if (!lp || + !lp->ma) { + return NULL; + } + + lp->cur = lp->ma->start; + + return lp->cur; +} + +/** + * Get the next line in a parsing pass with a line parser. + * + * Each invocation of this function returns a pointer to consecutive lines in + * the buffer to parse. + * After the last line has been reached, NULL is returned. + * In that case, parsing can restart by calling hip_lp_first(). + * + * @param lp the line parser parser to use. + * @return a pointer to a line in the buffer or NULL if there are no more lines + * available. + */ +static inline char *hip_lp_next(struct hip_line_parser *const lp) +{ + size_t remaining; + + if (!lp || + !lp->cur || + !lp->ma || + !lp->ma->start || + !lp->ma->end || + lp->cur < lp->ma->start || + lp->cur >= lp->ma->end) { + return NULL; + } + + remaining = lp->ma->end - lp->cur; + lp->cur = memchr(lp->cur, '\n', remaining); + + // given the rest of the parsing code, we should always find a \n, but + // let's check to be sure + if (lp->cur) { + // cur should not point to the new-line character but to the next one: + lp->cur += 1; + // is there text on the line here or are we at the end? + if (lp->cur >= lp->ma->end) { + lp->cur = NULL; + } + } + + return lp->cur; +} #endif /* HIP_FIREWALL_LINE_PARSER_H */ === removed file 'firewall/line_parser_inline.h' --- firewall/line_parser_inline.h 2010-11-12 17:49:42 +0000 +++ firewall/line_parser_inline.h 1970-01-01 00:00:00 +0000 @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2010 Aalto University and RWTH Aachen University. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * @file - * @author Stefan Goetz <stefan.goetz@xxxxxxxxxxxxxxxxx> - */ - -#ifndef HIP_FIREWALL_LINE_PARSER_INLINE_H -#define HIP_FIREWALL_LINE_PARSER_INLINE_H - -/* On the one hand, the contents of this file are part of the public interface - * and thus only their declaration should go into the public header file. - * On the other hand, these functions should be inlineable so their definitions - * have to appear in a header file. - * To achieve inlineability and still hide the implementation, we use this - * secondary header file that is not part of the public interface. */ -#ifndef HIP_FIREWALL_LINE_PARSER_H -#error This file must not be included directly because it contains implementation details. It may only be included by line_parser.h. -#endif - -#include <string.h> - -#include "lib/core/debug.h" -#include "file_buffer.h" - -/** - * Represents the parsing state on a memory area object. - */ -struct hip_line_parser { - /** - * The memory area this parser operates on. - */ - const struct hip_mem_area *ma; - /** - * The current parsing position. - * If NULL, hip_lp_first() needs to be called. - * If != NULL, points to the start of line in the memory buffer. - */ - char *cur; -}; - -/** - * Start a new parsing pass with a line parser and return the first line in the - * buffer. - * The buffer is not modified and the line is terminated by a newline - * character (not a null character). - * - * A parsing pass consists of starting it via hip_lp_first() and iterating over - * the lines in the file via hip_lp_next() until it returns NULL. - * - * @param lp the line parser to use. - * @return a pointer to the first line in the file or NULL if no line is - * available. - */ -static inline char *hip_lp_first(struct hip_line_parser *const lp) -{ - if (!lp || - !lp->ma) { - return NULL; - } - - lp->cur = lp->ma->start; - - return lp->cur; -} - -/** - * Get the next line in a parsing pass with a line parser. - * - * Each invocation of this function returns a pointer to consecutive lines in - * the buffer to parse. - * After the last line has been reached, NULL is returned. - * In that case, parsing can restart by calling hip_lp_first(). - * - * @param lp the line parser parser to use. - * @return a pointer to a line in the buffer or NULL if there are no more lines - * available. - */ -static inline char *hip_lp_next(struct hip_line_parser *const lp) -{ - size_t remaining; - - if (!lp || - !lp->cur || - !lp->ma || - !lp->ma->start || - !lp->ma->end || - lp->cur < lp->ma->start || - lp->cur >= lp->ma->end) { - return NULL; - } - - remaining = lp->ma->end - lp->cur; - lp->cur = memchr(lp->cur, '\n', remaining); - - // given the rest of the parsing code, we should always find a \n, but - // let's check to be sure - if (lp->cur) { - // cur should not point to the new-line character but to the next one: - lp->cur += 1; - // is there text on the line here or are we at the end? - if (lp->cur >= lp->ma->end) { - lp->cur = NULL; - } - } - - return lp->cur; -} - -#endif /* HIP_FIREWALL_LINE_PARSER_INLINE_H */ === modified file 'firewall/port_bindings.c' --- firewall/port_bindings.c 2010-11-15 21:21:47 +0000 +++ firewall/port_bindings.c 2010-11-15 21:31:26 +0000 @@ -44,6 +44,7 @@ #include "lib/core/ife.h" #include "line_parser.h" #include "port_bindings.h" +#include "file_buffer.h" /** * The number of seconds after which hip_port_bindings_trigger_reload() is