Commit 937a72ea authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

remove unecessary files / address cpp check

parent adcfc433
This diff is collapsed.
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license and the GPL. Refer to the accompanying documentation for details
* on usage and license.
*/
/*
* bstraux.h
*
* This file is not a necessary part of the core bstring library itself, but
* is just an auxilliary module which includes miscellaneous or trivial
* functions.
*/
#ifndef BSTRAUX_INCLUDE
#define BSTRAUX_INCLUDE
#include <time.h>
#include "bstrlib.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Safety mechanisms */
#define bstrDeclare(b) bstring (b) = NULL;
#define bstrFree(b) {if ((b) != NULL && (b)->slen >= 0 && (b)->mlen >= (b)->slen) { bdestroy (b); (b) = NULL; }}
/* Backward compatibilty with previous versions of Bstrlib */
#if !defined(BSTRLIB_REDUCE_NAMESPACE_POLLUTION)
#define bAssign(a,b) ((bassign)((a), (b)))
#define bSubs(b,pos,len,a,c) ((breplace)((b),(pos),(len),(a),(unsigned char)(c)))
#define bStrchr(b,c) ((bstrchr)((b), (c)))
#define bStrchrFast(b,c) ((bstrchr)((b), (c)))
#define bCatCstr(b,s) ((bcatcstr)((b), (s)))
#define bCatBlk(b,s,len) ((bcatblk)((b),(s),(len)))
#define bCatStatic(b,s) bcatStatic(b,s)
#define bTrunc(b,n) ((btrunc)((b), (n)))
#define bReplaceAll(b,find,repl,pos) ((bfindreplace)((b),(find),(repl),(pos)))
#define bUppercase(b) ((btoupper)(b))
#define bLowercase(b) ((btolower)(b))
#define bCaselessCmp(a,b) ((bstricmp)((a), (b)))
#define bCaselessNCmp(a,b,n) ((bstrnicmp)((a), (b), (n)))
#define bBase64Decode(b) (bBase64DecodeEx ((b), NULL))
#define bUuDecode(b) (bUuDecodeEx ((b), NULL))
#endif
/* Unusual functions */
extern struct bStream * bsFromBstr (const_bstring b);
extern bstring bTail (bstring b, int n);
extern bstring bHead (bstring b, int n);
extern int bSetCstrChar (bstring a, int pos, char c);
extern int bSetChar (bstring b, int pos, char c);
extern int bFill (bstring a, char c, int len);
extern int bReplicate (bstring b, int n);
extern int bReverse (bstring b);
extern int bInsertChrs (bstring b, int pos, int len, unsigned char c, unsigned char fill);
extern bstring bStrfTime (const char * fmt, const struct tm * timeptr);
#define bAscTime(t) (bStrfTime ("%c\n", (t)))
#define bCTime(t) ((t) ? bAscTime (localtime (t)) : NULL)
/* Spacing formatting */
extern int bJustifyLeft (bstring b, int space);
extern int bJustifyRight (bstring b, int width, int space);
extern int bJustifyMargin (bstring b, int width, int space);
extern int bJustifyCenter (bstring b, int width, int space);
/* Esoteric standards specific functions */
extern char * bStr2NetStr (const_bstring b);
extern bstring bNetStr2Bstr (const char * buf);
extern bstring bBase64Encode (const_bstring b);
extern bstring bBase64DecodeEx (const_bstring b, int * boolTruncError);
extern struct bStream * bsUuDecode (struct bStream * sInp, int * badlines);
extern bstring bUuDecodeEx (const_bstring src, int * badlines);
extern bstring bUuEncode (const_bstring src);
extern bstring bYEncode (const_bstring src);
extern bstring bYDecode (const_bstring src);
extern int bSGMLEncode (bstring b);
/* Writable stream */
typedef int (* bNwrite) (const void * buf, size_t elsize, size_t nelem, void * parm);
struct bwriteStream * bwsOpen (bNwrite writeFn, void * parm);
int bwsWriteBstr (struct bwriteStream * stream, const_bstring b);
int bwsWriteBlk (struct bwriteStream * stream, void * blk, int len);
int bwsWriteFlush (struct bwriteStream * stream);
int bwsIsEOF (const struct bwriteStream * stream);
int bwsBuffLength (struct bwriteStream * stream, int sz);
void * bwsClose (struct bwriteStream * stream);
/* Security functions */
#define bSecureDestroy(b) { \
bstring bstr__tmp = (b); \
if (bstr__tmp && bstr__tmp->mlen > 0 && bstr__tmp->data) { \
(void) memset (bstr__tmp->data, 0, (size_t) bstr__tmp->mlen); \
bdestroy (bstr__tmp); \
} \
}
#define bSecureWriteProtect(t) { \
if ((t).mlen >= 0) { \
if ((t).mlen > (t).slen)) { \
(void) memset ((t).data + (t).slen, 0, (size_t) (t).mlen - (t).slen); \
} \
(t).mlen = -1; \
} \
}
extern bstring bSecureInput (int maxlen, int termchar,
bNgetc vgetchar, void * vgcCtx);
#ifdef __cplusplus
}
#endif
#endif
...@@ -2115,6 +2115,9 @@ int bsreadlna (bstring r, struct bStream * s, char terminator) { ...@@ -2115,6 +2115,9 @@ int bsreadlna (bstring r, struct bStream * s, char terminator) {
int i, l, ret, rlo; int i, l, ret, rlo;
char * b; char * b;
struct tagbstring x; struct tagbstring x;
x.mlen = 0;
x.slen = 0;
x.data = NULL;
if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 || if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 ||
r->slen < 0 || r->mlen < r->slen) return BSTR_ERR; r->slen < 0 || r->mlen < r->slen) return BSTR_ERR;
...@@ -2181,6 +2184,9 @@ int i, l, ret, rlo; ...@@ -2181,6 +2184,9 @@ int i, l, ret, rlo;
unsigned char * b; unsigned char * b;
struct tagbstring x; struct tagbstring x;
struct charField cf; struct charField cf;
x.mlen = 0;
x.slen = 0;
x.data = NULL;
if (s == NULL || s->buff == NULL || r == NULL || term == NULL || if (s == NULL || s->buff == NULL || r == NULL || term == NULL ||
term->data == NULL || r->mlen <= 0 || r->slen < 0 || term->data == NULL || r->mlen <= 0 || r->slen < 0 ||
......
This diff is collapsed.
/*
* This source file is part of the bstring string library. This code was
* written by Paul Hsieh in 2002-2015, and is covered by the BSD open source
* license. Refer to the accompanying documentation for details on usage and
* license.
*/
/*
* testaux.c
*
* This file is the C unit test for the bstraux module of Bstrlib.
*/
#include <stdio.h>
#include "bstrlib.h"
#include "bstraux.h"
static int tWrite (const void * buf, size_t elsize, size_t nelem, void * parm) {
bstring b = (bstring) parm;
size_t i;
if (NULL == b || NULL == buf || 0 == elsize || 0 == nelem)
return -__LINE__;
for (i=0; i < nelem; i++) {
if (0 > bcatblk (b, buf, elsize)) break;
buf = (const void *) (elsize + (const char *) buf);
}
return (int) i;
}
int test0 (void) {
struct bwriteStream * ws;
bstring s;
int ret = 0;
printf ("TEST: struct bwriteStream functions.\n");
ws = bwsOpen ((bNwrite) tWrite, (s = bfromcstr ("")));
bwsBuffLength (ws, 8);
ret += 8 != bwsBuffLength (ws, 0);
bwsWriteBlk (ws, bsStaticBlkParms ("Hello "));
ret += 0 == biseqcstr (s, "");
bwsWriteBlk (ws, bsStaticBlkParms ("World\n"));
ret += 0 == biseqcstr (s, "Hello Wo");
ret += s != bwsClose (ws);
ret += 0 == biseqcstr (s, "Hello World\n");
printf ("\t# failures: %d\n", ret);
return ret;
}
int test1 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c, d;
int ret = 0;
printf ("TEST: bTail and bHead functions.\n");
b = bTail (&t, 5);
c = bHead (&t, 5);
ret += 0 >= biseqcstr (b, "world");
ret += 0 >= biseqcstr (c, "Hello");
bdestroy (b);
bdestroy (c);
b = bTail (&t, 0);
c = bHead (&t, 0);
ret += 0 >= biseqcstr (b, "");
ret += 0 >= biseqcstr (c, "");
bdestroy (b);
bdestroy (c);
d = bstrcpy (&t);
b = bTail (d, 5);
c = bHead (d, 5);
ret += 0 >= biseqcstr (b, "world");
ret += 0 >= biseqcstr (c, "Hello");
bdestroy (b);
bdestroy (c);
bdestroy (d);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test2 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0, reto;
printf ("TEST: bSetChar function.\n");
ret += 0 <= bSetChar (&t, 4, ',');
ret += 0 > bSetChar (b = bstrcpy (&t), 4, ',');
ret += 0 >= biseqcstr (b, "Hell, world");
ret += 0 <= bSetChar (b, -1, 'x');
b->slen = 2;
ret += 0 > bSetChar (b, 1, 'i');
ret += 0 >= biseqcstr (b, "Hi");
ret += 0 > bSetChar (b, 2, 's');
ret += 0 >= biseqcstr (b, "His");
ret += 0 > bSetChar (b, 1, '\0');
ret += blength (b) != 3;
ret += bchare (b, 0, '?') != 'H';
ret += bchare (b, 1, '?') != '\0';
ret += bchare (b, 2, '?') != 's';
bdestroy (b);
printf ("\t# failures: %d\n", ret);
reto = ret;
ret = 0;
printf ("TEST: bSetCstrChar function.\n");
ret += 0 <= bSetCstrChar (&t, 4, ',');
ret += 0 > bSetCstrChar (b = bstrcpy (&t), 4, ',');
ret += 0 >= biseqcstr (b, "Hell, world");
ret += 0 <= bSetCstrChar (b, -1, 'x');
b->slen = 2;
ret += 0 > bSetCstrChar (b, 1, 'i');
ret += 0 >= biseqcstr (b, "Hi");
ret += 0 > bSetCstrChar (b, 2, 's');
ret += 0 >= biseqcstr (b, "His");
ret += 0 > bSetCstrChar (b, 1, '\0');
ret += blength (b) != 1;
ret += bchare (b, 0, '?') != 'H';
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return reto + ret;
}
int test3 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bFill function.\n");
ret += 0 <= bFill (&t, 'x', 7);
ret += 0 > bFill (b = bstrcpy (&t), 'x', 7);
ret += 0 >= biseqcstr (b, "xxxxxxx");
ret += 0 <= bFill (b, 'x', -1);
ret += 0 > bFill (b, 'x', 0);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test4 (void) {
struct tagbstring t = bsStatic ("foo");
bstring b;
int ret = 0;
printf ("TEST: bReplicate function.\n");
ret += 0 <= bReplicate (&t, 4);
ret += 0 <= bReplicate (b = bstrcpy (&t), -1);
ret += 0 > bReplicate (b, 4);
ret += 0 >= biseqcstr (b, "foofoofoofoo");
ret += 0 > bReplicate (b, 0);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test5 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bReverse function.\n");
ret += 0 <= bReverse (&t);
ret += 0 > bReverse (b = bstrcpy (&t));
ret += 0 >= biseqcstr (b, "dlrow olleH");
b->slen = 0;
ret += 0 > bReverse (b);
ret += 0 >= biseqcstr (b, "");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test6 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
int ret = 0;
printf ("TEST: bInsertChrs function.\n");
ret += 0 <= bInsertChrs (&t, 6, 4, 'x', '?');
ret += 0 > bInsertChrs (b = bstrcpy (&t), 6, 4, 'x', '?');
ret += 0 >= biseqcstr (b, "Hello xxxxworld");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test7 (void) {
struct tagbstring t = bsStatic (" i am ");
bstring b;
int ret = 0;
printf ("TEST: bJustify functions.\n");
ret += 0 <= bJustifyLeft (&t, ' ');
ret += 0 <= bJustifyRight (&t, 8, ' ');
ret += 0 <= bJustifyMargin (&t, 8, ' ');
ret += 0 <= bJustifyCenter (&t, 8, ' ');
ret += 0 > bJustifyLeft (b = bstrcpy (&t), ' ');
ret += 0 >= biseqcstr (b, "i am");
ret += 0 > bJustifyRight (b, 8, ' ');
ret += 0 >= biseqcstr (b, " i am");
ret += 0 > bJustifyMargin (b, 8, ' ');
ret += 0 >= biseqcstr (b, "i am");
ret += 0 > bJustifyCenter (b, 8, ' ');
ret += 0 >= biseqcstr (b, " i am");
bdestroy (b);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test8 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b;
char * c;
int ret = 0;
printf ("TEST: NetStr functions.\n");
c = bStr2NetStr (&t);
ret += 0 != strcmp (c, "11:Hello world,");
b = bNetStr2Bstr (c);
ret += 0 >= biseq (b, &t);
bdestroy (b);
bcstrfree (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test9 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c;
int err, ret = 0;
printf ("TEST: Base 64 codec.\n");
b = bBase64Encode (&t);
ret += 0 >= biseqcstr (b, "SGVsbG8gd29ybGQ=");
c = bBase64DecodeEx (b, &err);
ret += 0 != err;
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test10 (void) {
struct tagbstring t = bsStatic ("Hello world");
bstring b, c;
int err, ret = 0;
printf ("TEST: UU codec.\n");
b = bUuEncode (&t);
ret += 0 >= biseqcstr (b, "+2&5L;&\\@=V]R;&0`\r\n");
c = bUuDecodeEx (b, &err);
ret += 0 != err;
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test11 (void) {
struct tagbstring t = bsStatic ("Hello world");
unsigned char Ytstr[] = {0x72, 0x8f, 0x96, 0x96, 0x99, 0x4a, 0xa1, 0x99, 0x9c, 0x96, 0x8e};
bstring b, c;
int ret = 0;
printf ("TEST: Y codec.\n");
b = bYEncode (&t);
ret += 11 != b->slen;
ret += 0 >= bisstemeqblk (b, Ytstr, 11);
c = bYDecode (b);
ret += 0 >= biseq (c, &t);
bdestroy (b);
bdestroy (c);
printf ("\t# failures: %d\n", ret);
return ret;
}
int test12 (void) {
struct tagbstring t = bsStatic ("Hello world");
struct bStream * s;
bstring b;
int ret = 0;
printf ("TEST: bsFromBstr.\n");
ret = bsread (b = bfromcstr (""), s = bsFromBstr (&t), 6);
ret += 1 != biseqcstr (b, "Hello ");
if (b) b->slen = 0;
ret = bsread (b, s, 6);
ret += 1 != biseqcstr (b, "world");
bdestroy (b);
bsclose (s);
printf ("\t# failures: %d\n", ret);
return ret;
}
struct vfgetc {
int ofs;
bstring base;
};
static int test13_fgetc (void * ctx) {
struct vfgetc * vctx = (struct vfgetc *) ctx;
int c;
if (NULL == vctx || NULL == vctx->base) return EOF;
if (vctx->ofs >= blength (vctx->base)) return EOF;
c = bchare (vctx->base, vctx->ofs, EOF);
vctx->ofs++;
return c;
}
int test13 (void) {
struct tagbstring t0 = bsStatic ("Random String, long enough to cause to reallocing");
struct vfgetc vctx;
bstring b;
int ret = 0;
int i;
printf ("TEST: bSecureInput, bSecureDestroy.\n");
for (i=0; i < 1000; i++) {
unsigned char * h;
vctx.ofs = 0;
vctx.base = &t0;
b = bSecureInput (INT_MAX, '\n', (bNgetc) test13_fgetc, &vctx);
ret += 1 != biseq (b, &t0);
h = b->data;
bSecureDestroy (b);
/* WARNING! Technically undefined code follows (h has been freed): */
ret += (0 == memcmp (h, t0.data, t0.slen));
if (ret) break;
}
printf ("\t# failures: %d\n", ret);
return ret;
}
int test14_aux(bstring b, const char* chkVal) {
int ret = 0;
ret += 0 != bSGMLEncode (b);
ret += 1 != biseqcstr (b, chkVal);
return ret;
}
int test14 (void) {
bstring b;
int ret = 0;
printf ("TEST: bSGMLEncode.\n");
ret += test14_aux (b = bfromStatic ("<\"Hello, you, me, & world\">"), "&lt;&quot;Hello, you, me, &amp; world&quot;&gt;");
printf ("\t# failures: %d\n", ret);
return ret;
}
/*
int main () {
int ret = 0;
printf ("Direct case testing of bstraux functions\n");
ret += test0 ();
ret += test1 ();
ret += test2 ();
ret += test3 ();
ret += test4 ();
ret += test5 ();
ret += test6 ();
ret += test7 ();
ret += test8 ();
ret += test9 ();
ret += test10 ();
ret += test11 ();
ret += test12 ();
ret += test13 ();
ret += test14 ();
printf ("# test failures: %d\n", ret);
return 0;
}
*/
...@@ -1649,7 +1649,7 @@ void smf_context::handle_pdu_session_update_sm_context_request( ...@@ -1649,7 +1649,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//Only one flow description for new requested QoS Flow //Only one flow description for new requested QoS Flow
QOSFlowDescriptionsContents *qos_flow_description = QOSFlowDescriptionsContents *qos_flow_description =
(QOSFlowDescriptionsContents*) calloc( (QOSFlowDescriptionsContents*) calloc(
1, sizeof(QOSFlowDescriptionsContents)); number_of_flow_descriptions, sizeof(QOSFlowDescriptionsContents));
if (number_of_flow_descriptions > 0) { if (number_of_flow_descriptions > 0) {
qos_flow_description = decoded_nas_msg.plain.sm qos_flow_description = decoded_nas_msg.plain.sm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment