diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/Makefile.am | 1 | ||||
-rw-r--r-- | src/libstrongswan/utils/lexparser.c | 40 | ||||
-rw-r--r-- | src/libstrongswan/utils/lexparser.h | 5 | ||||
-rw-r--r-- | src/libstrongswan/utils/memrchr.c | 45 |
4 files changed, 3 insertions, 88 deletions
diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am index aa0e1d83e..1463d415f 100644 --- a/src/libstrongswan/Makefile.am +++ b/src/libstrongswan/Makefile.am @@ -47,7 +47,6 @@ utils/identification.c utils/identification.h \ utils/iterator.h \ utils/lexparser.c utils/lexparser.h \ utils/linked_list.c utils/linked_list.h \ -utils/memrchr.c \ utils/hashtable.c utils/hashtable.h \ utils/enumerator.c utils/enumerator.h \ utils/optionsfrom.c utils/optionsfrom.h \ diff --git a/src/libstrongswan/utils/lexparser.c b/src/libstrongswan/utils/lexparser.c index c351e7e24..c1816d6eb 100644 --- a/src/libstrongswan/utils/lexparser.c +++ b/src/libstrongswan/utils/lexparser.c @@ -14,16 +14,8 @@ * $Id$ */ -/* memrchr is a GNU extension */ -#define _GNU_SOURCE -#include <string.h> - #include "lexparser.h" -#ifndef HAVE_MEMRCHR -void *memrchr(const void *s, int c, size_t n); -#endif - /** * eat whitespace */ @@ -33,7 +25,7 @@ bool eat_whitespace(chunk_t *src) { src->ptr++; src->len--; } - return src->len > 0 && *src->ptr != '#'; + return src->len > 0 && *src->ptr != '#'; } /** @@ -54,11 +46,11 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src) if (termination == ' ') { u_char *eot_tab = memchr(src->ptr, '\t', src->len); - + /* check if a tab instead of a space terminates the token */ eot = ( eot_tab == NULL || (eot && eot < eot_tab) ) ? eot : eot_tab; } - + /* initialize empty token */ *token = chunk_empty; @@ -106,32 +98,6 @@ bool extract_token_str(chunk_t *token, const char *termination, chunk_t *src) } /** - * extracts a token ending with the last occurrence of a given termination symbol - */ -bool extract_last_token(chunk_t *token, const char termination, chunk_t *src) -{ - u_char *eot = memrchr(src->ptr, termination, src->len); - - /* initialize empty token */ - *token = chunk_empty; - - if (eot == NULL) /* termination symbol not found */ - { - return FALSE; - } - - /* extract token */ - token->ptr = src->ptr; - token->len = (u_int)(eot - src->ptr); - - /* advance src pointer after termination symbol */ - src->ptr = eot + 1; - src->len -= (token->len + 1); - - return TRUE; -} - -/** * fetches a new line terminated by \n or \r\n */ bool fetchline(chunk_t *src, chunk_t *line) diff --git a/src/libstrongswan/utils/lexparser.h b/src/libstrongswan/utils/lexparser.h index 46a715b21..41b1c1765 100644 --- a/src/libstrongswan/utils/lexparser.h +++ b/src/libstrongswan/utils/lexparser.h @@ -47,11 +47,6 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src); bool extract_token_str(chunk_t *token, const char *termination, chunk_t *src); /** - * Extracts a token ending with the last occurrence of a given termination symbol - */ -bool extract_last_token(chunk_t *token, const char termination, chunk_t *src); - -/** * Fetches a new text line terminated by \n or \r\n */ bool fetchline(chunk_t *src, chunk_t *line); diff --git a/src/libstrongswan/utils/memrchr.c b/src/libstrongswan/utils/memrchr.c deleted file mode 100644 index efcd03aa0..000000000 --- a/src/libstrongswan/utils/memrchr.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2008 Thomas Jarosch - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef HAVE_MEMRCHR - -#include <string.h> - -void *memrchr(const void *s, int c, size_t n) -{ - unsigned char *reverse_search; - - if (s == NULL || n == 0) - { - return NULL; - } - - reverse_search = s + n; - - for (;;) - { - if (*reverse_search == (unsigned char)c) - { - return reverse_search; - } - else if (reverse_search == s) - { - break; - } - reverse_search--; - } - return NULL; -} - -#endif |