comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: call_external (IDL5.5)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: call_external (IDL5.5) [message #29474] Tue, 26 February 2002 10:43 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Reimar Bauer <r.bauer@fz-juelich.de> writes:

> James Kuyper wrote:
...
>> Which points out he importance of using "#include export.h" to create
>> the typedef, rather than copying the typedef into your own code.
>
> I agree to this and sure this was the main problem.
>
> The second problem comes from this two lines.
>
> strcpy(buf,path.s);
> buf[path.slen]='\0';
>
> I have learned that I have to do:
>
> buf[path.slen]='\0';
> strcpy(buf,path.s);

Reimar, this does not sound right. The use of strcpy() is rather
unsafe, and you should prefer strncpy(). Also, there is the risk that
the "path" string is longer than buf[]. Then what do you do?

Safer approach:

char buf[NCHAR];
int len;

if (path.slen >= NCHAR) len = NCHAR-1; else len = path.slen;
if (len > 0) strncpy(buf, path.s, len);
buf[len] = 0;

If the "path" is too long for the buf[], then this code truncates it.

Cheers,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL books?
Next Topic: Re: Satellite orbit procedure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 09:34:39 PDT 2025

Total time taken to generate the page: 0.56031 seconds