[Asterisk-Users] Script AGI on C

Diego Aguirre dag.voip at oi.com.br
Mon May 22 08:50:01 MST 2006


Oi...

eu respondi sua mensagem na lista asteriskbrasil, mas com a moderação 
dela, só deve chegar amanhã, hehehe

tenta um strip no arquivo.

# strip executable.agi

isso deve reduzir mais um pouco o tamanho do seu arquivo...

Diego Aguirre
Infodag - Informática
FWD#: 459696
Nikotel#: 99 21 8138-2710
EnumLookup#: +55 21 8138-2710
DUNDi-br#: 21 8138-2710


cleviton.araujo at caixa.gov.br escreveu:
> Hi Folks:
> 
> I used that one example for AGI script on C web, only to fill the working with the Asterisk. I compiled and it worked great. I executed accidentally the ls -l command in directory where was the source and executable, I noted and was surprised that because the executable size was to further 20 times more than source.
> 
> I executed the gcc -Os source.c -o executable.agi command several times, with otimization flags different. Maximum i can affort to reduce the executable size was 17 times.
> 
> The source size full comment is 448 Bytes;
> The size executable was about 7615 Bytes. (the maximum i got to reduce)
> 
> I was hope the executable size was in the order of magnitude of the proper source size, since the comments are long.
> 
> Do one get to explain because of this?
> Is this overhead consequence of linking with the operational system?
> The script use only four functions of stdio.h library. It was seem that the compiler include all stdio.h functions and compile all them.
> 
> I would like somebody of list to clear my doubt.
> 
> Regards,
> Cleviton.
> 
> 
> Here below small script used I grasp on site: http://home.cogeco.ca/~camstuff/agi.html
> 
> /* C works just fine with Asterisk but you should use 'setlinebuf' on stdout and stderr. This causes buffering one line at a time 
> (rather than using a larger buffer). If you *don't* do this on stdout then your script will hang up while Asterisk waits for a 
> command but the (long) buffer isn't full yet. A minimal AGI script in C looks like this: */
> //
>    #include <stdio.h>
>    main() {
>        char        line[80];
>        /* use line buffering */
>        setlinebuf(stdout);
>        setlinebuf(stderr);
>        /* read and ignore AGI environment */
>        while (1) {
>            fgets(line,80,stdin);
>            if (strlen(line) <= 1) break;
>        }
>        /* Send asterisk a command */
>        printf("SAY NUMBER 123 \"\"\n");
>        /* Read response from Asterisk and show on console */
>        fgets(line,80,stdin);
>        fputs(line,stderr);
>    }
> 
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
> 
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
> 
> 



More information about the asterisk-users mailing list