Re: getargs question

Sjoerd Mullender (Sjoerd.Mullender@cwi.nl)
Thu, 11 Aug 1994 10:03:48 +0200

On Mon, Aug 8 1994 Monty wrote:

> I don't understand why I'm stumped on this. It must be pretty easy.
> I'm exporting a function that I want to be called like this:
>
> export.playSound(audiodata,len(audiodata),1,1,22050.0)
>
> in my C function playSound(object *dummy,object *args) I call getargs as
> such:
>
> res = getargs(args,"(siiif)",&data,&bytelen,&tag,&channels
> ,&samplingRate);
>
> It fails, returning zero. The data variable has been set to the right
> thing but nothing else is. Why might this not be working?

You don't need to specify the length of the audiodata, because getargs
can find that for you. In fact, it is better if you let getargs do
that, since if you don't, getargs will complain if there are NUL bytes
in the string that you passed. This is undoubtedly also the reason
why getargs is failing.

The following should work. Call the function as follows:

export.playSound(audiodata,1,1,22050.0)

In your C function, call getargs as follows:

res = getargs(args,"(s#iif)",&data,&bytelen,&tag,&channels,&samplingRate);

Notice the #.

Sjoerd Mullender, CWI, P.O. Box 94079, 1090 GB Amsterdam, The Netherlands
E-Mail: Sjoerd.Mullender@cwi.nl; Phone: +31 20 592 4127; Fax: +31 20 592 4199
URL: <http://www.cwi.nl/cwi/people/Sjoerd.Mullender.html>