<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
It doesn't work with the environment either:<br>
<font color="#3366ff">Port = open_port({spawn, SharedLib}, [{env,
[{"PARM1","p1"},{"PARM2","p2"},{"PARM3","p3"}]}]),</font><br>
Sebastian-<br>
<br>
Sebastian Bello escribió:
<blockquote cite="mid47D6CB68.5000705@inswitch.us" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hi Per,<br>
<br>
thanks for your response.<br>
Ideally I would like to perform something like<br>
<br>
<font color="#3366ff">Port = open_port({spawn, "./mylib parm1
parm2"},
[])</font><br>
<br>
at the Erlang side, and be able to parse <i>parmN </i>from the C side:<br>
<br>
<font color="#3366ff">static ErlDrvData driver_start(ErlDrvPort port,
char *buff) {<br>
<br>
// parse parameters from *buff<br>
}</font><br>
<br>
That's all; is that possible with a linked-in driver?<br>
Thanks,<br>
Sebastian-<br>
<br>
<br>
Per Hedeland escribió:
<blockquote cite="mid200803082102.m28L2s1H060375@pluto.hedeland.org"
type="cite">
<pre wrap="">Sebastian Bello <a class="moz-txt-link-rfc2396E"
href="mailto:sebastian.bello@inswitch.us"><sebastian.bello@inswitch.us></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">There is no argc/argv in a linked in driver as far as I know.
</pre>
</blockquote>
<pre wrap=""><!---->
Hm, it was a while ago, but according to your quote I wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">(An external port program would (at least on *nix) get
the Command in the argc/argv arguments to main()...)
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
I'm sorry, but I'm quite unable to parse that as a claim that a driver
would get argc/argv, so I have no idea why you feel the need to state
that it doesn't. But you're quite correct of course.
</pre>
<blockquote type="cite">
<pre wrap="">On the
driver side you have
static ErlDrvData driver_start(ErlDrvPort port, char *buff)
</pre>
</blockquote>
<pre wrap=""><!---->
Exactly, and as I recall your question was what was in the "buff", which
I explained.
</pre>
<blockquote type="cite">
<pre wrap="">and buff just points to the driver name;
</pre>
</blockquote>
<pre wrap=""><!---->
It points to (a C-style copy of) whatever string you passed to
open_port/2. As far as open_port is concerned, the driver name ends at
the first space (which is quite analogous to / consistent with how the
string is parsed in the case of an external port program, though I
hesitate to mention it...).
</pre>
<blockquote type="cite">
<pre wrap="">if you load the driver with
parameters you just get an "open_error".
</pre>
</blockquote>
<pre wrap=""><!---->
Please share the code that gives that result. Of course open_port
doesn't "load the driver", but I assume it's open_port you're talking
about - anyway that's what *I* am talking about. I'm successfully using
the technique I described in commercial product code - in fact it's used
in the OTP code too, e.g. in the dbg module.
</pre>
<blockquote type="cite">
<pre wrap="">Any other ideas?
</pre>
</blockquote>
<pre wrap=""><!---->
None needed.
--Per
__________ NOD32 2933 (20080310) Information __________
This message was checked by NOD32 antivirus system.
<a class="moz-txt-link-freetext" href="http://www.eset.com">http://www.eset.com</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>