[Mono-list] Wrapper additions

Dietmar Maurer dietmar@ximian.com
Wed, 19 Sep 2001 08:40:28 +0200


Hi Jim,

feel free to commit. Although I wonder how you get the name of a
directory. We also need thread safe code, and do we really need
mono_wrapper_environ?

- Dietmar


Jim Richardson wrote:

> Here they are in diff -u.
> I'll be happy to commit them on dietmar's all clear if that is easier.
>
> jrichardson@JIMR-LAPTOP ~
> $ cd cvsmono/mono/mono/wrapper
>
> jrichardson@JIMR-LAPTOP ~/cvsmono/mono/mono/wrapper
> $ cvs diff -u genwrapper.pl wrapper.c
> Enter passphrase for key '/home/jrichardson/.ssh/id_rsa':
> Index: genwrapper.pl
> ===================================================================
> RCS file: /cvs/public/mono/mono/wrapper/genwrapper.pl,v
> retrieving revision 1.4
> diff -u -r1.4 genwrapper.pl
> --- genwrapper.pl       2001/09/10 09:03:07     1.4
> +++ genwrapper.pl       2001/09/19 01:01:15
> @@ -71,6 +71,21 @@
>  create_func ($lib, "", "unlink", "int",
>              "string", "path");
>
> +create_func ($lib, "", "opendir", "IntPtr",
> +            "string", "path");
> +
> +create_func ($lib, "", "readdir", "IntPtr",
> +            "IntPtr", "dir");
> +
> +create_func ($lib, "", "closedir", "int",
> +            "IntPtr", "dir");
> +
> +create_func ($lib, "", "getenv", "IntPtr",
> +            "string", "variable");
> +
> +create_func ($lib, "", "environ", "IntPtr");
> +
> +
>  map_const ("int", "%d", "SEEK_SET",
>            "int", "%d", "SEEK_CUR",
>            "int", "%d", "SEEK_END",
> Index: wrapper.c
> ===================================================================
> RCS file: /cvs/public/mono/mono/wrapper/wrapper.c,v
> retrieving revision 1.2
> diff -u -r1.2 wrapper.c
> --- wrapper.c   2001/09/10 07:39:00     1.2
> +++ wrapper.c   2001/09/19 01:01:15
> @@ -1,5 +1,7 @@
>  #include <config.h>
>  #include <limits.h>
> +#include <dirent.h>
> +#include <stdlib.h>
>
>  #include "wrapper.h"
>
> @@ -93,3 +95,34 @@
>         return unlink(path);
>  }
>
> +int
> +mono_wrapper_opendir (const char * path)
> +{
> +       return (int)opendir(path);
> +}
> +
> +int
> +mono_wrapper_readdir (int dir)
> +{
> +       /* WARNING: Not thread safe */
> +       return (int)readdir((DIR*)dir);
> +}
> +
> +gint32
> +mono_wrapper_closedir (int dir)
> +{
> +       return closedir((DIR*)dir);
> +}
> +
> +int
> +mono_wrapper_getenv (const char * variable)
> +{
> +       /* WARNING: Not thread safe */
> +       return (int)getenv(variable);
> +}
> +
> +int
> +mono_wrapper_environ ()
> +{
> +       return (int)environ;
> +}
>
> jrichardson@JIMR-LAPTOP ~/cvsmono/mono/mono/wrapper
> $