HP3000-L Archives

October 1997, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ross Scroggs <[log in to unmask]>
Reply To:
Ross Scroggs <[log in to unmask]>
Date:
Wed, 1 Oct 1997 11:56:21 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (75 lines)
On Wednesday, October 01, 1997 4:32 AM, Bob Walker
[SMTP:[log in to unmask]] wrote:
> We  just upgraded to MPE 5.5 Express2(from 5.0) on the weekend  and
> now JTMAIL(by Jim Wowchuk) is now behaving strangly.
>
> We run JTMAIL from a job, setting some environment variables first.
> Specifically there are character pointers that can get set either
> from the command line, if present, or from env variables if not.
>
> Problem lies in when getting settings from env variables.
> As each getenv is called, char pointers defined from previous getenvs
> are all set to the value of the most recent call to getenv.
>
> eg:
> [from job]
> :  SETVAR HOST "delphi"
> :  SETVAR MAILHOST "mail.capcollege.bc.ca"
> :  SETVAR MAILPORT "SMTP"
> :  SETVAR MAILUSER "[log in to unmask]"
>
> [from code]
> char *gszLocalHost = NULL;   /* the name of the host we're on */
> char *gszMailHost = NULL;     /* name of the host running SMTP */
> char *gszMailPort = NULL;    /* the TCP service port  */
> char *gszUser = NULL;       /* the email address for replies */
> .....
> gszLocalHost = getenv("HOST");
> ShowVars(1);   /* debug - show all gsz.... variables if not NULL */
> gszMailHost = getenv("MAILHOST");
> ShowVars(2);
> gszMailPort = getenv("PORT");
> ShowVars(3);
> gszUser = getenv("MAILUSER");
> ShowVars(4);
>
> [Output]
> * 1 * HOST     : delphi
>
> * 2 * MAILHOST : mail.capcollege.bc.ca
> * 2 * HOST     : mail.capcollege.bc.ca
>
> * 3 * MAILHOST : SMTP
> * 3 * MAILPORT : SMTP
> * 3 * HOST     : SMTP
>
> * 4 * MAILHOST : [log in to unmask]
> * 4 * MAILUSER : [log in to unmask]
> * 4 * MAILPORT : [log in to unmask]
> * 4 * HOST     : [log in to unmask]
>
> ----
> This program worked fine up until upgrade to 5.5.
> The workaround we are using  is to supply all info on the command
> line.
> Any ideas??
> Bob.
>
> --=--=--
> Bob Walker, Computer Centre  --  [log in to unmask]
> Capilano College, North Vancouver, BC, CANADA.
> ------
> 'There are over 600 books on the millennium(so far).
> 110 of them spell it wrong.'

This is exactly the behavior that you should expect. getenv(3C) states
that the pointer returned points to a static area that can be
overwritten
by subsequent calls. After each call, copy the string to another array.

-----
Ross Scroggs                    Voice: (510) 987-7700 x104
Telamon, Inc.                   Email: [log in to unmask]
492 Ninth Street, Suite 310     FAX:   (510) 987-7009
Oakland, CA  94607-4098

ATOM RSS1 RSS2