All pastes #49123 Raw Edit

Untitled

public text v1 · immutable
#49123 ·published 2006-04-12 03:56 UTC
rendered paste body
Function AgiCmd(Cmd : String) : TAgiResult;
Var
    Response            : String;
    result1              : TAgiResult;
    Code                : Integer;
    C, J                : Integer;
Begin;
    {send command to Asterisk}
    //Log('Command:'+Cmd+':');

    Writeln(Cmd);
    {read response}
    Readln(Response);
    //Log('Response:'+Response+':');
    result1.StringRes := Response;
    {AsteriskWriteln('Response:'+Response);
    MyLog('Response is: '+Cmd+' :: '+Response);
    MyLog('UseFul :: '+GetUsefulResult(result1));}
    If (Length(Response) < 12) or (Copy(Response,1,11) <> '200 result=') then begin;
        {we didn't get the response we were expecting}
          Log('Blad AgiCMD!');
          result1.IntRes := -1;
          result1.StringRes := '-1';
          AgiCmd := result1;
          {Halt;}
          {MyLog('About to do Callback from <12');}
          DoCallBack;
          {Paranoia!}
          {Halt;}
    End;
    {Trim the '200 result=' off the front of the response}
    Response := Copy(Response,12,Length(Response));
    {Take only the numeric portion}
    C := 0;
    For J := 1 to Length(Response) do begin;
        If Response[J] in ['0'..'9','-'] then
            Inc(C)
        Else
            BREAK;
    End;
################################################################
there is more code, but it crashes on line 11, the writeln().
here is some gdb stuff i did
###############################################################

Breakpoint 2, AGICMD (CMD=0x80f1050, result={STRINGRES = 0x0, INTRES = 1}) at agi.pas:247
247         Writeln(Cmd);
(gdb) x/s cmd
0x80f1050 <HEAP+10160>:  'GET VARIABLE tbcc_who'
(gdb) continue
Continuing.
GET VARIABLE tbcc_who
200 result=1 (111161777)

Breakpoint 2, AGICMD (CMD=0x80f0920, result={STRINGRES = 0x0, INTRES = 1}) at agi.pas:247
247         Writeln(Cmd);
(gdb) x/s cmd
0x80f0920 <HEAP+8320>:   'GET VARIABLE tbcc_where'
(gdb) continue
Continuing.
GET VARIABLE tbcc_where
200 result=1 (81046531)

Breakpoint 2, AGICMD (CMD=0x80f5d10, result={STRINGRES = 0x0, INTRES = -848}) at agi.pas:247
247         Writeln(Cmd);
(gdb) x/s cmd
0x80f5d10 <HEAP+29808>:  'EXEC SetLanguage au'
(gdb) next

Program exited normally.
(gdb) continueQuit
(gdb) quit