Shared Library, common function

  • Follow


Hello,

 I have created a shared library, so any tool within project shared most 
commonly used functions.

 One of the functions looks like this:

FILE *db_fifo() {
    FILE *fifo;

    fifo = fopen("/somewhere/db","w");
    if (fifo)
        return fifo;

    return NULL;
}

 unfortunately after the function returns, nobody is able to use the fifo, 
because it is invalid.

 Is it possible to use a shared libarary and return usable resources like a 
pointer to FILE?


P.Krumins
0
Reply Peteris 7/1/2003 7:14:48 PM

In article <Xns93ABE22592A41whitesuneapollolv@130.133.1.4>,
Peteris Krumins  <pkruminsREMOVETHIS@inbox.lv> wrote:
>Hello,
>
> I have created a shared library, so any tool within project shared most 
>commonly used functions.
>
> One of the functions looks like this:
>
>FILE *db_fifo() {
>    FILE *fifo;
>
>    fifo = fopen("/somewhere/db","w");
>    if (fifo)
>        return fifo;
>
>    return NULL;
>}
>
> unfortunately after the function returns, nobody is able to use the fifo, 
>because it is invalid.
>
> Is it possible to use a shared libarary and return usable resources like a 
>pointer to FILE?

Of course it is.  fopen() is also in a shared library, and it returns a
pointer to FILE that's usable.

There must be something else wrong with your code.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
0
Reply Barry 7/1/2003 8:27:48 PM


Peteris Krumins wrote:
> 
>  Is it possible to use a shared libarary and return usable resources like a 
> pointer to FILE?

Sure.  What system are you using?  If you are in a pseudo-UNIX 
environment (i.e. cygwin, u/win...) under ms-windows this can be a big 
issue.

-- ced




-- 
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

0
Reply Chuck 7/3/2003 2:30:00 PM

Chuck Dillon <cdillon@nimblegen.com> wrote in
news:3F043DE8.9030204@nimblegen.com: 

> Peteris Krumins wrote:
>> 
>>  Is it possible to use a shared libarary and return usable resources
>>  like a 
>> pointer to FILE?
> 
> Sure.  What system are you using?  If you are in a pseudo-UNIX 
> environment (i.e. cygwin, u/win...) under ms-windows this can be a big
> issue.

Thanks for the comment, i have already solved the problem, as my function 
the library was more compicated than i posted, i didnt notice a small bug 
which affected the pointer to be returned.
And, i am not programming in a pseudo-unix env.


P.Krumins
0
Reply Peteris 7/5/2003 8:05:49 PM

3 Replies
208 Views

(page loaded in 0.057 seconds)

Similiar Articles:













7/9/2012 8:15:05 AM


Reply: