Tools/DiskTool - Add test script
[tpg/acess2.git] / AcessNative / libacess-native.so_src / main.c
index f072864..900a14c 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
 extern int     giSyscall_ClientID;
 extern void    Request_Preinit(void);
@@ -19,13 +20,28 @@ int DllMain(void)
 #endif
 
 #ifdef __linux__
-int __attribute__ ((constructor)) libacessnative_init(void);
+int __attribute__ ((constructor(102))) libacessnative_init(int argc, char *argv[], char **envp);
 
-int libacessnative_init(void)
+const char *getenv_p(char **envp, const char *name)
 {
-       Request_Preinit();
+       size_t  namelen = strlen(name);
+       for(; *envp; envp ++)
+       {
+               if( strncmp(*envp, name, namelen) != 0 )
+                       continue ;
+               if( (*envp)[namelen] != '=' )
+                       continue ;
+               return (*envp)+namelen+1;
+       }
+       return 0;
+}
 
-       const char *preopens = getenv("AN_PREOPEN");
+int libacessnative_init(int argc, char *argv[], char **envp)
+{
+       Request_Preinit();
+       
+       const char *preopens = getenv_p(envp, "AN_PREOPEN");
+       printf("preopens = %s\n", preopens);
        if( preopens )
        {
                while( *preopens )

UCC git Repository :: git.ucc.asn.au