linked-in driver

Shawn Pearce spearce@REDACTED
Wed Jun 1 05:03:18 CEST 2005

Serge Aleynikov <serge@REDACTED> wrote:
> I need to pass parameters to the start function of a linked-in driver, 
> but I am not sure how this can be done.
> The start function accepts a char* command.  Is there a way to pass 
> anything there besides the driver's name?
> int start(ErlDrvPort port, char* command);
> After examining erlang:open_port/2 I found the {env, Environment} 
> option, but I believe it only works for port drivers.
> Any advice on the subject is appreciated.

Pass the parameters as part of the driver string to open_port.  E.g.

erlang:open_port("mydrv param1 param2", ...)

will give you the string "mydrv param1 param2" in the command parameter
of the start function in your C code.  You will have to parse out the
parameters on your own.  I believe the only requirement on the format
of this string is that the characters leading up to the first ASCII
space match the name of the driver; the rest is left up to the driver.


More information about the erlang-questions mailing list