Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //function to extract a tag from the string given in bcdata by tag ID
- function extract_tag(tag_id:PAnsiChar; abcdata:PAnsiChar;var rsltdata:PAnsiChar):integer;
- var
- bflen:integer;
- tslen:integer;
- stpos:integer;
- rfln:integer;
- s_len:string;
- eos:boolean;
- pp:PAnsiChar;
- begin
- writeln('TAG '+tag_id+' bcdata '+abcdata);
- writeln('String len in et '+IntToStr(strlen(abcdata)+1));
- tslen:=strlen(abcdata);
- if tslen = 0 then
- begin
- result:=-1;
- exit;
- end;
- eos:=false;
- stpos:=0;
- while (eos=false) do
- begin
- pp:=Stralloc(4);
- strlcopy(pp,@abcdata[stpos],3);
- s_len:=StrPas(pp);
- StrDispose(pp);
- rfln:=StrToInt(s_len);
- writeln('FLEN '+tag_id+' bcdata '+abcdata);
- if ((rfln=0) or (stpos > tslen)) then
- begin
- eos:=true;
- result:=-1;
- exit;
- end;
- if (rfln > tslen) then
- begin
- eos:=true;
- result:=-1;
- exit;
- end;
- //ok if we are here we compare the tag id with the extracted one
- pp:= stralloc(3);
- strlcopy(pp,@abcdata[stpos+3],2);
- if strlicomp(tag_id,pp,2) = 0 then
- begin
- strlcopy(rsltdata,@abcdata[stpos+5],rfln);
- eos:=true;
- result:=0;
- end
- else
- begin
- stpos:=stpos+rfln+5;
- //advance to next field
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement