2 *****************************************************************************
6 * Author: Damien Stuart (dstuart@dstuart.org)
8 * Purpose: Header file for utils.c fwknopd server program.
10 * Copyright 2010 Damien Stuart (dstuart@dstuart.org)
12 * License (GNU Public License):
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 *****************************************************************************
36 #define CTX_DUMP_BUFSIZE 4096
38 /* Some convenience macros */
40 /* Characters allowed between a config parameter and its value.
42 #define IS_CONFIG_PARAM_DELIMITER(x) (x == ' ' || x == '\t' || x == '=');
44 /* String compare macro.
46 #define CONF_VAR_IS(n, v) (strcmp(n, v) == 0)
48 /* End of line characters.
50 #define IS_LINE_END(x) (x == '\n' || x == '\r' || x == ';');
52 /* Characters in the first position of a line that make it considered
53 * empty or otherwise non-interesting (like a comment).
55 #define IS_EMPTY_LINE(x) ( \
56 x == '#' || x == '\n' || x == '\r' || x == ';' || x == '\0' \
61 void hex_dump(const unsigned char *data, const int size);
62 char* dump_ctx(fko_ctx_t ctx);
63 int is_base64(const unsigned char *buf, unsigned short int len);
64 int is_valid_dir(const char *path);
65 int set_file_perms(const char *file);
66 int verify_file_perms_ownership(const char *file);
68 size_t strlcat(char *dst, const char *src, size_t siz);
69 size_t strlcpy(char *dst, const char *src, size_t siz);