Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
105 user(s) are online (94 user(s) are browsing Forums)

Members: 0
Guests: 105

more...

Support us!

Headlines

 
  Register To Post  

ScanVars() usage examples.
Just can't stay away
Just can't stay away


See User information
I did find references to

SourceForge ABC-shell's environ.c
and AROS __env_get_environ()
using ScanVars to get hold of subsets (i hope) or the env variables.

I would be glad to be able to consult them, as both are open-source initiatives can somebody point me to a download URL ?


Go to top
Re: ScanVars() usage examples.
Just can't stay away
Just can't stay away


See User information
@JosDuchIt
Sourceforge had a catastrophic system failure about 12 days ago. They have been slowly restoring services ever since. Subversion repositories have been fully restored but their latest status indicates that they are still in the process of restoring CVS services so CVS projects like abc-shell & others don't have the sourcecode restored yet.

ABC-shell is at: https://sourceforge.net/projects/abc-shell/?source=directory

Once the Sourceforge restoration is complete you should be able to go to that page and click the big blue "Browse Code" button to see & download the file you need.

As far as AROS system sources, the AROS project is on Sourceforge but the sources are not publicly accessible. If I remember correctly, during the court battle of who owns AmigaOS sources the AROS team was forced to limit access to the sources to AROS system developers. I could be wrong but I think that's the case.

Old "make" and "abc-shell" sources were included in SDK 51.22 and the make sources also have scanvars routines.

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: ScanVars() usage examples.
Home away from home
Home away from home


See User information
abc-shell environ routines that use ScanVars to scan the global variables or the local varaiables only when a specific car is set (that enables nested shells to inherit from the parent not the global state).



#include "sh.h"
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/var.h>
#include <utility/hooks.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>

char **environ NULL;


#if defined(__amigaos4__)

#define MAX_ENV_SIZE 1024  /* maximum number of environ entries */

#ifdef AUTOINIT
#ifdef __GNUC__
void ___makeenviron() __attribute__((constructor));
void ___freeenviron() __attribute__((destructor));
#endif
#ifdef __VBCC__
#define ___makeenviron() _INIT_9_makeenviron()
#define ___freeenviron() _EXIT_9_makeenviron()
#endif
#endif


uint32
copy_env
(struct Hook *hookAPTR userdatastruct ScanVarsMsg *message)
{
        static 
uint32 env_size 1;  /* environ is null terminated */

        
if(strlen(message->sv_GDir) <= 4)
        {
                if ( 
env_size == MAX_ENV_SIZE )
                {
                        return 
0;
                }

                
char **env = (char **)hook->h_Data;
                
uint32 size strlen(message->sv_Name) + message->sv_VarLen 1;
                
char *buffer=(char *)malloc(size);
                if ( 
buffer == NULL )
                {
                        return 
0;
                }

                ++
env_size;

                
snprintf(buffer,size-1,"%s=%s"message->sv_Namemessage->sv_Var);

                *
env  buffer;
                
env++;
                
hook->h_Data env;
        }

        return 
0;
}

void
___makeenviron
()
{
        
char varbuf[8];
        
uint32 flags=0;
        
size_t environ_size=MAX_ENV_SIZE sizeof(char*);

        if(
GetVar("ABCSH_IMPORT_LOCAL",varbuf,sizeof(varbuf),GVF_LOCAL_ONLY) > 0)
        {
            
flags GVF_LOCAL_ONLY;
        }
        else
        {
            
flags GVF_GLOBAL_ONLY;
        }

        
environ = (char **)malloc(environ_size);
        if (!
environ)
        {
                return;
        }

        
memset(environ0environ_size);

        
struct Hook hook;
        
memset(&hook0sizeof(struct Hook));
        
hook.h_Entry copy_env;
        
hook.h_Data environ;

        
ScanVars(&hookflags0);
}

void
___freeenviron
()
{
        if ( 
environ != NULL )
        {
                
char **i;
                for ( 
environ; *!= NULLi++ )
                {
                        
free(*i);
                        *
NULL;
                }

                
free(environ);
                
environ NULL;
        }
}
#endif

Go to top
Re: ScanVars() usage examples.
Just popping in
Just popping in


See User information

Go to top
Re: ScanVars() usage examples.
Just can't stay away
Just can't stay away


See User information
@xenix
thanks for links , infortunately
the ABC-shell link (sourceforge) does not work for me (error msg "unable to open" the file
The oldest SDK i have are those presently still on the Hyperion site (53.13)
@broadblues Thanks for the ABC-shell functions

I modified it & compiled it to print the env variables.


Edited by JosDuchIt on 2015/7/28 13:27:46
Edited by JosDuchIt on 2015/7/28 18:33:55
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project