1. What is the equivalent EU expression

Hi,

I am trying to call a C func from EU, the C Func is described as:
SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, SQLINTEGER
FAR *OutputHandle);
where SQLINTEGER is of type long.

What will be the equivalent EU code.

Regards,
Prasanta.

new topic     » topic index » view message » categorize

2. Re: What is the equivalent EU expression

It's a pointer, so I believe SQLINTEGER FAR * would just be C_POINTER (and
passed as an atom).

Jeff Fielding

Prasanta Chakraborty wrote:

> Hi,
>
> I am trying to call a C func from EU, the C Func is described as:
> SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, SQLINTEGER
> FAR *OutputHandle);
> where SQLINTEGER is of type long.
>
> What will be the equivalent EU code.
>
> Regards,
> Prasanta.

new topic     » goto parent     » topic index » view message » categorize

3. Re: What is the equivalent EU expression

On Wed, 15 Mar 2000 21:51:30 -0500, Prasanta Chakraborty
<prasanta at WRITEME.COM> wrote:

>Hi,
>
>I am trying to call a C func from EU, the C Func is described as:
>SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, SQLINTEGER
>FAR *OutputHandle);
>where SQLINTEGER is of type long.
>
>What will be the equivalent EU code.
>
>Regards,
>Prasanta.

Prasanta,

What you ask is actually a 2-part process.  First you must define the c
function (and the DLL it lives in) in the context of your program using
open_dll() and define_c_func().  Here's an example:

global constant wsock32 = open_dll("wsock32.dll")
global constant func_WSAStartup = define_c_func(wsock32,"WSAStartup",
    {C_SHORT,C_POINTER},C_INT)

This "links" the DLL to your program, and declares func_WSAStartup as an
external C function that takes C types SHORT(euphoria integer) and POINTER
(euphoria atom) as arguments, and returns a type INT(euphoria atom).

Now to use the function, you would need to do this:

integer arg1
atom arg2
atom returnValue

-- you need to assign the appropriate values to arg1 and arg2 here
returnValue = c_func(func_WSAStartup, {arg1, arg2})

Also, Fabio Ramirez has written a very nice MySQL interface for Euphoria
which may either be exactly what you need, or at least give you some good
examples of how to wrap SQL API functions using Euphoria.

Hope this helps!

Brian

new topic     » goto parent     » topic index » view message » categorize

4. Re: What is the equivalent EU expression

Hi Brian

One small thing with your example for prasanta. I seem to remember that
inputs to C functions must all be atoms so I think the "integer arg1" might
need to be "atom arg1". I seem to remember getting an error something like
"inputs to C functions must be atoms" once before.

If I'm wrong please ignore

Mark



----- Original Message -----
From: Brian Jackson <bjackson at 2FARGON.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Thursday, March 16, 2000 1:33
Subject: Re: What is the equivalent EU expression


> On Wed, 15 Mar 2000 21:51:30 -0500, Prasanta Chakraborty
> <prasanta at WRITEME.COM> wrote:
>
> >Hi,
> >
> >I am trying to call a C func from EU, the C Func is described as:
> >SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, SQLINTEGER
> >FAR *OutputHandle);
> >where SQLINTEGER is of type long.
> >
> >What will be the equivalent EU code.
> >
> >Regards,
> >Prasanta.
>
> Prasanta,
>
> What you ask is actually a 2-part process.  First you must define the c
> function (and the DLL it lives in) in the context of your program using
> open_dll() and define_c_func().  Here's an example:
>
> global constant wsock32 = open_dll("wsock32.dll")
> global constant func_WSAStartup = define_c_func(wsock32,"WSAStartup",
>     {C_SHORT,C_POINTER},C_INT)
>
> This "links" the DLL to your program, and declares func_WSAStartup as an
> external C function that takes C types SHORT(euphoria integer) and POINTER
> (euphoria atom) as arguments, and returns a type INT(euphoria atom).
>
> Now to use the function, you would need to do this:
>
> integer arg1
> atom arg2
> atom returnValue
>
> -- you need to assign the appropriate values to arg1 and arg2 here
> returnValue = c_func(func_WSAStartup, {arg1, arg2})
>
> Also, Fabio Ramirez has written a very nice MySQL interface for Euphoria
> which may either be exactly what you need, or at least give you some good
> examples of how to wrap SQL API functions using Euphoria.
>
> Hope this helps!
>
> Brian

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu