diff options
author | Lev Walkin <vlm@lionet.info> | 2004-10-22 08:17:16 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2004-10-22 08:17:16 +0000 |
commit | dde25b3e7be8122b4712c18977667091e73fdc58 (patch) | |
tree | 49e332c5db470adc9482c917b2aaad6d59ce9145 | |
parent | 867ac199266b3382d56ae78d8cc1a3e135c79153 (diff) |
xer_is_whitespace()
-rw-r--r-- | skeletons/BOOLEAN.c | 11 | ||||
-rw-r--r-- | skeletons/asn_codecs_prim.c | 27 | ||||
-rw-r--r-- | skeletons/xer_decoder.c | 23 | ||||
-rw-r--r-- | skeletons/xer_decoder.h | 8 |
4 files changed, 35 insertions, 34 deletions
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c index cfecd491..7473b626 100644 --- a/skeletons/BOOLEAN.c +++ b/skeletons/BOOLEAN.c @@ -137,7 +137,6 @@ static ssize_t BOOLEAN__xer_body_decode(void *sptr, void *chunk_buf, size_t chunk_size) { BOOLEAN_t *st = (BOOLEAN_t *)sptr; char *p = (char *)chunk_buf; - char *pend = p + chunk_size; if(chunk_size == 0) return -1; @@ -158,14 +157,8 @@ BOOLEAN__xer_body_decode(void *sptr, void *chunk_buf, size_t chunk_size) { return -1; } } else { - for(; p < pend; p++) { - switch(*p) { - case 0x09: case 0x0a: case 0x0d: case 0x20: - break; - default: - return -1; /* Not whitespace */ - } - } + if(!xer_is_whitespace(chunk_buf, chunk_size)) + return -1; } return chunk_size; diff --git a/skeletons/asn_codecs_prim.c b/skeletons/asn_codecs_prim.c index e6725b37..089e54ee 100644 --- a/skeletons/asn_codecs_prim.c +++ b/skeletons/asn_codecs_prim.c @@ -143,29 +143,6 @@ struct xdp_arg_s { int want_more; }; -/* - * Check whether this buffer consists of entirely XER whitespace characters. - */ -static int -xer_decode__check_whitespace(void *chunk_buf, size_t chunk_size) { - char *p = (char *)chunk_buf; - char *pend = p + chunk_size; - for(; p < pend; p++) { - switch(*p) { - /* X.693, #8.1.4 - * HORISONTAL TAB (9) - * LINE FEED (10) - * CARRIAGE RETURN (13) - * SPACE (32) - */ - case 0x09: case 0x0a: case 0x0d: case 0x20: - break; - default: - return 0; - } - } - return 1; /* All whitespace */ -} static int xer_decode__unexpected_tag(void *key, void *chunk_buf, size_t chunk_size) { @@ -173,7 +150,7 @@ xer_decode__unexpected_tag(void *key, void *chunk_buf, size_t chunk_size) { ssize_t decoded; if(arg->decoded_something) { - if(xer_decode__check_whitespace(chunk_buf, chunk_size)) + if(xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size; /* * Decoding was done once already. Prohibit doing it again. @@ -197,7 +174,7 @@ xer_decode__body(void *key, void *chunk_buf, size_t chunk_size, int have_more) { ssize_t decoded; if(arg->decoded_something) { - if(xer_decode__check_whitespace(chunk_buf, chunk_size)) + if(xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size; /* * Decoding was done once already. Prohibit doing it again. diff --git a/skeletons/xer_decoder.c b/skeletons/xer_decoder.c index 9cbccf81..b7bc83bb 100644 --- a/skeletons/xer_decoder.c +++ b/skeletons/xer_decoder.c @@ -290,3 +290,26 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, RETURN(RC_FAIL); } + +int +xer_is_whitespace(void *chunk_buf, size_t chunk_size) { + char *p = (char *)chunk_buf; + char *pend = p + chunk_size; + + for(; p < pend; p++) { + switch(*p) { + /* X.693, #8.1.4 + * HORISONTAL TAB (9) + * LINE FEED (10) + * CARRIAGE RETURN (13) + * SPACE (32) + */ + case 0x09: case 0x0a: case 0x0d: case 0x20: + break; + default: + return 0; + } + } + return 1; /* All whitespace */ +} + diff --git a/skeletons/xer_decoder.h b/skeletons/xer_decoder.h index b8aef662..1c26ef79 100644 --- a/skeletons/xer_decoder.h +++ b/skeletons/xer_decoder.h @@ -79,4 +79,12 @@ ssize_t xer_next_token(int *stateContext, void *buffer, size_t size, xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, const char *need_tag); +/* + * Check whether this buffer consists of entirely XER whitespace characters. + * RETURN VALUES: + * 1: Whitespace or empty string + * 0: Non-whitespace + */ +int xer_is_whitespace(void *chunk_buf, size_t chunk_size); + #endif /* _XER_DECODER_H_ */ |