Chameleon

Chameleon Commit Details

Date:2015-03-12 04:34:25 (4 years 8 months ago)
Author:ErmaC
Commit:2619
Parents: 2618
Message:Safety check, typo and NULL (xml.c)
Changes:
M/trunk/i386/libsaio/xml.c

File differences

trunk/i386/libsaio/xml.c
133133
134134
135135
136
136
137137
138138
139139
......
152152
153153
154154
155
155
156156
157157
158158
......
255255
256256
257257
258
258
259
260
261
262
259263
260
261
262
263
264
265
266
264
267265
268
269
270
271
272
273
274
266
267
268
269
270
271
272
273
275274
275
276
277
276278
277279
278280
......
372374
373375
374376
377
375378
376
377
378
379379
380380
381381
......
533533
534534
535535
536
537
538
539
540
536541
537542
538543
......
607612
608613
609614
610
615
611616
612617
613618
......
626631
627632
628633
629
634
630635
631636
632637
......
643648
644649
645650
646
651
647652
648653
649654
......
659664
660665
661666
662
667
663668
664669
665670
......
700705
701706
702707
703
708
704709
705710
706711
707712
708713
709714
710
715
711716
712717
713718
......
740745
741746
742747
743
748
744749
745750
746751
747752
748753
749
754
750755
751756
752757
......
754759
755760
756761
757
758
762
763
759764
760765
761766
......
860865
861866
862867
863
868
864869
865
870
866871
867872
868873
......
886891
887892
888893
889
894
890895
891896
892897
......
899904
900905
901906
902
907
903908
904909
905
910
906911
907912
908913
......
924929
925930
926931
927
932
928933
929934
930935
......
933938
934939
935940
936
937
938
941
942
943
939944
940945
941946
......
951956
952957
953958
954
959
955960
956961
957962
958963
959964
960
961
962
965
966
967
963968
964969
970
965971
966972
967973
......
975981
976982
977983
978
984
979985
980986
981987
......
10541060
10551061
10561062
1057
1058
1063
10591064
10601065
10611066
10621067
10631068
1064
1069
10651070
10661071
1067
1072
10681073
1069
1074
10701075
10711076
10721077
......
10941099
10951100
10961101
1097
1102
10981103
10991104
11001105
......
11091114
11101115
11111116
1112
1113
1117
1118
11141119
11151120
11161121
......
11321137
11331138
11341139
1135
1140
11361141
11371142
11381143
......
11471152
11481153
11491154
1150
1155
11511156
11521157
1153
1154
1158
1159
11551160
11561161
11571162
......
11821187
11831188
11841189
1185
1190
11861191
11871192
11881193
1189
1194
11901195
11911196
11921197
......
12001205
12011206
12021207
1203
1208
12041209
12051210
12061211
......
12211226
12221227
12231228
1229
1230
1231
1232
1233
12241234
1225
1235
12261236
12271237
12281238
......
12351245
12361246
12371247
1238
1248
12391249
12401250
12411251
if (dict->type != kTagTypeDict)
{
return 0;
return NULL;
}
tag = 0;
return tag->tag;
}
}
return 0;
return NULL;
}
//==========================================================================
return tmp;
}
/* Function for basic XML character entities parsing */
typedef const struct XMLEntity {
const char *name;
size_t nameLen;
char value;
} XMLEntity;
char *XMLDecode(const char* src)
{
typedef const struct XMLEntity {
const char *name;
size_t nameLen;
char value;
} XMLEntity;
/* This is ugly, but better than specifying the lengths by hand */
/* This is ugly, but better than specifying the lengths by hand */
#define _e(str,c) {str,sizeof(str)-1,c}
const XMLEntity ents[] = {
_e("quot;",'"'), _e("apos;",'\''),
_e("lt;", '<'), _e("gt;", '>'),
_e("amp;", '&')
};
#define _e(str,c) {str,sizeof(str)-1,c}
const XMLEntity ents[] = {
_e("quot;",'"'), // double quotation mark
_e("apos;",'\''), // ampersand
_e("lt;", '<'), // apostrophe (apostrophe-quote)
_e("gt;", '>'), // less-than sign
_e("amp;", '&') // greater-than sign
};
/* Function for basic XML character entities parsing */
char *XMLDecode(const char *src)
{
size_t len;
const char *s;
char *out, *o;
{
longlength = 0;
longpos = 0;
char*tagName = NULL;
char*tagName;
length = GetNextTag(buffer, &tagName, 0);
if (length == -1)
{
int integer = (int)GetRefString(id);
TagPtr tmpTag = NewTag();
if (tmpTag == 0)
{
return -1;
}
tmpTag->type = kTagTypeInteger;
tmpTag->string = (char*) integer;
tmpTag->tag = 0;
else
{
// it wasn't parsed so we consumed no additional characters
*tag = 0;
*tag = NULL;
length = 0;
}
{
longpos = 0;
longlength = 0;
TagPtrtagList = 0;
TagPtrtagList = NULL;
TagPtrtmpTag;
pos += length;
// detect end of list
if (tmpTag == 0)
if (tmpTag == NULL)
{
break;
}
}
tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
XMLFreeTag(tagList);
return -1;
}
tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
XMLFreeTag(subTag);
return -1;
}
string = NewSymbol(buffer);
if (string == 0)
if (string == NULL)
{
XMLFreeTag(subTag);
XMLFreeTag(tmpTag);
}
TagPtr tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
return -1;
}
string = NewSymbol(buffer);
if (string == 0)
if (string == NULL)
{
XMLFreeTag(tmpTag);
return -1;
tmpTag->type = kTagTypeString;
tmpTag->string = string;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->tag = NULL;
tmpTag->tagNext = NULL;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
*tag = tmpTag;
tmpTag->type = kTagTypeInteger;
tmpTag->string = (char *)integer;
tmpTag->tag = 0;
tmpTag->tag = NULL;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
tmpTag->tagNext = NULL;
*tag = tmpTag;
}
tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
return -1;
}
tmpTag->type = kTagTypeData;
tmpTag->string = string;
tmpTag->tag = 0;
tmpTag->tag = NULL;
tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0;
tmpTag->tagNext = 0;
tmpTag->tagNext = NULL;
*tag = tmpTag;
}
tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
return -1;
}
getchar();
tmpTag->type = kTagTypeDate;
tmpTag->string = 0;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->string = NULL;
tmpTag->tag = NULL;
tmpTag->tagNext = NULL;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
*tag = tmpTag;
TagPtr tmpTag;
tmpTag = NewTag();
if (tmpTag == 0)
if (tmpTag == NULL)
{
return -1;
}
tmpTag->type = type;
tmpTag->string = 0;
tmpTag->tag = 0;
tmpTag->tagNext = 0;
tmpTag->string = NULL;
tmpTag->tag = NULL;
tmpTag->tagNext = NULL;
tmpTag->offset = buffer_start ? buffer - buffer_start: 0;
*tag = tmpTag;
return 0;
longcnt;
longcnt2;
if (tag == 0)
if (tag == NULL)
{
return -1;
}
#define kTagsPerBlock (0x1000)
static TagPtr gTagsFree;
static TagPtr gTagsFree= NULL;
static TagPtr NewTag( void )
{
longcnt;
TagPtrtag;
if (gTagsFree == 0)
if (gTagsFree == NULL)
{
tag = (TagPtr)malloc(kTagsPerBlock *sizeof(Tag));
if (tag == 0)
if (tag == NULL)
{
return 0;
return NULL;
}
// Initalize the new tags.
void XMLFreeTag( TagPtr tag )
{
#if DOFREE
if (tag == 0)
if (tag == NULL)
{
return;
}
// Clear and free the tag.
tag->type = kTagTypeNone;
tag->string = 0;
tag->tag = 0;
tag->string = NULL;
tag->tag = NULL;
tag->offset = 0;
tag->tagNext = gTagsFree;
gTagsFree = tag;
static SymbolPtr FindSymbol(char *string, SymbolPtr *prevSymbol);
static SymbolPtr gSymbolsHead;
static SymbolPtr gSymbolsHead= NULL;
//==========================================================================
// NewSymbol
symbol = FindSymbol(string, 0);
// Add the new symbol.
if (symbol == 0)
if (symbol == NULL)
{
symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string));
if (symbol == 0)
{//return 0;
if (symbol == NULL)
{
stop("NULL symbol!");
}
static void FreeSymbol( char *string )
{
SymbolPtr symbol, prev;
prev = 0;
prev = NULL;
// Look for string in the list of symbols.
symbol = FindSymbol(string, &prev);
if (symbol == 0)
if (symbol == NULL)
{
return;
}
}
// Remove the symbol from the list.
if (prev != 0)
if (prev != NULL)
{
prev->next = symbol->next;
}
{
SymbolPtr symbol, prev;
if (string == NULL)
{
return NULL;
}
symbol = gSymbolsHead;
prev = 0;
prev = NULL;
while (symbol != NULL)
{
symbol = symbol->next;
}
if ((symbol != 0) && (prevSymbol != 0))
if ((symbol != NULL) && (prevSymbol != NULL))
{
*prevSymbol = prev;
}

Archive Download the corresponding diff file

Revision: 2619