Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
52 user(s) are online (39 user(s) are browsing Forums)

Members: 1
Guests: 51

Templario, more...
Support us!
Recent OS4 Files
OS4Depot.net





Is setenv() works with newlib ?
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
Tried some simple test case :

#include <stdio.h>
#include <stdlib.h>

int main()
{
setenv("TEST_ENV","0"1);
}


Then spawn a shell, compile, run, and in the same shell trying to "getenv TEST_ENV" return me object not found. I.e. environment wasn't set.

Is it expected with newlib to be like this, like its not out setenv, but just some local setenv in unix style ?

Is there some os4 native mechanism to set environment globally from C code ? I of course can just do something like IDOS->System("setenv TEST_ENV 0", NULL); , but not sure if it right thing to do like this.

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: Is setenv() works with newlib ?
Home away from home
Joined:
2006/12/4 23:15
Posts: 2144
@kas1e

setenv() set a local variable (visible with getenv()) which will be inherited by all sub processes, it does not set the global ENV: variables or even the local shel variables. THis might not be obvious as the intial set of variables *is* imported from the Amiga environment.

To access / modify the amiga envoronment use IDOS->GetVar(), IDOS->SetVar(), etc.

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Is setenv() works with newlib ?
Just can't stay away
Joined:
2009/5/1 17:57
From Czech Republic
Posts: 1058
@kas1e

Quote:
I of course can just do something like IDOS->System("setenv TEST_ENV 0", NULL); , but not sure if it right thing to do like this.

No it's not. Look at SetVar() in the DOS autodocs.

_________________
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top

Re: Is setenv() works with newlib ?
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
@Andy,Dan
Yeah, SetVar is what i need indeed, thanks!

EDIT: should it works for the current process from which is set ?

I.e. i have a game, for which i need special environment set, so i do set it right at begining of main(), but it seems it didn't take action for that binary, while in system it all looks like environment was set.

I.e. i just do it like this:

IDOS->SetVar("MYENV", "40", 2, GVF_GLOBAL_ONLY);

And while when i do in another shell "getenv MYENV" while game is running, i have correct "40" in otuput, but it seems that it didn't taken in action for the binary from which i run it.

Just in case i tried and GVF_LOCAL_ONLY mode too, same result..

EDIT2:

Same if i just tried "IDOS->System("setenv LIBGL_BATCH 0-40", NULL);" , it also didn't takes in action when i run it from begining of main() before actual code which want to check on that environment (but when i run second time, it then take it).

Test cases works fine through, but inside of game it is not. Strange ! Like it use code which is check variable way before main()

EDIT3:

Oh sorry for spam , found why it didn't works : check on that environment was indeed in constructor, so before main().


Edited by kas1e on 2019/10/17 14:47:32
Edited by kas1e on 2019/10/17 14:51:47
Edited by kas1e on 2019/10/17 17:11:36
Edited by kas1e on 2019/10/17 17:19:50
Edited by kas1e on 2019/10/17 17:53:33
_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: Is setenv() works with newlib ?
Home away from home
Joined:
2006/12/4 23:15
Posts: 2144
@kas1e

I'm not sure that setting env vars from the main executable of program is a good idea, they are presumably for allowing the user to choose options, if you need those options permanently set then perhaps it would be better to override the code that checkc the env var.

If you still need them as options , then wrap the main executable in a script ( in the same way as 'blender' is ascript wrapping 'bldyn' or timberwolf etc).


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Is setenv() works with newlib ?
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
@broadblues
In my case that environemtn should be set 100%, or instead you will have visuall issues. I.e. that shouldn't be controlled by user. On running i do getvar() to grab current value (if there any), then set my one, and on exit restore original one. I also do set it localy for process now, so all should be fine

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project