File pointer to file handle

Discussion in 'C Programming' started by Apollyon, May 2, 2004.

  1. Apollyon

    Apollyon Guest

    I'm trying to figure out if there's a function that takes a file pointer
    (FILE *) and will return a HANDLE type ... I'm trying to modify some code
    and I've looked everywhere to no avail.

    Thanks
    --
    Apollyon




    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
     
    Apollyon, May 2, 2004
    #1
    1. Advertising

  2. Apollyon <> scribbled the following:
    > I'm trying to figure out if there's a function that takes a file pointer
    > (FILE *) and will return a HANDLE type ... I'm trying to modify some code
    > and I've looked everywhere to no avail.


    Seeing as HANDLE is not a standard C type, your question is off-topic
    here. Please ask in a newsgroup dedicated to your own operating system.

    An answer that would work within the contents of this newsgroup would
    be:

    #include <stdio.h>
    typedef FILE *HANDLE;
    HANDLE convert_file_ptr_to_handle(FILE *ptr) {
    return ptr;
    }

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "C++. C++ run. Run, ++, run."
    - JIPsoft
     
    Joona I Palaste, May 2, 2004
    #2
    1. Advertising

  3. Apollyon

    Apollyon Guest

    Yes, I know, I had tried there and wasn't getting a very rapid response so I
    figured I'd try here too. Oh well.

    --
    Apollyon

    "Joona I Palaste" <> wrote in message
    news:c7254b$3m$...
    > Apollyon <> scribbled the following:
    > > I'm trying to figure out if there's a function that takes a file pointer
    > > (FILE *) and will return a HANDLE type ... I'm trying to modify some

    code
    > > and I've looked everywhere to no avail.

    >
    > Seeing as HANDLE is not a standard C type, your question is off-topic
    > here. Please ask in a newsgroup dedicated to your own operating system.
    >
    > An answer that would work within the contents of this newsgroup would
    > be:
    >
    > #include <stdio.h>
    > typedef FILE *HANDLE;
    > HANDLE convert_file_ptr_to_handle(FILE *ptr) {
    > return ptr;
    > }
    >
    > --
    > /-- Joona Palaste () ------------- Finland --------\
    > \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    > "C++. C++ run. Run, ++, run."
    > - JIPsoft





    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
     
    Apollyon, May 2, 2004
    #3
  4. Apollyon

    Malcolm Guest

    "Apollyon" <> wrote in message
    > I'm trying to figure out if there's a function that takes a file pointer
    > (FILE *) and will return a HANDLE type ... I'm trying to modify
    > some code and I've looked everywhere to no avail.
    >

    On older implementations you often have low-level, unbuffered IO and
    functions like open(), read(), and write().
    These are not ANSI, are not supported on all platforms, and are virtually
    obsolete on a modern hosted system, because it is no longer possible to get
    significant performance increases by messing with the buffering.
    If you mix the fopen() family of functions with another IO family then you
    risk having problems, such as the stdio functions buffering input so it gets
    written in the wrong order.
    However if you are determined, there will probably be a function that gets a
    "handle" from a FILE *. If not, look at the structure members and one of
    them will probably be what you are looking for. However you are now leaving
    ANSI C land.
     
    Malcolm, May 2, 2004
    #4
  5. On Sun, 2 May 2004 00:44:59 -0600, in comp.lang.c , "Apollyon"
    <> wrote:

    >Yes, I know, I had tried there and wasn't getting a very rapid response so I
    >figured I'd try here too. Oh well.


    the obvious way to do this would be to use some platform-specific functions
    to find out the filename from the FILE*, then re-open it using the right
    platform-specific function.
    However you're going to have to read your compiler docs to find out how to
    do that.
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, May 2, 2004
    #5
  6. Apollyon

    CBFalconer Guest

    Apollyon wrote:
    >
    > I'm trying to figure out if there's a function that takes a file
    > pointer (FILE *) and will return a HANDLE type ... I'm trying to
    > modify some code and I've looked everywhere to no avail.


    There is no such thing as a HANDLE type in C, unless you define it
    yourself. Some systems have a non-standard function called
    "fileno(FILE *)", which you might look up on your system. The
    results are no-longer portable, and thus off-topic here.

    --
    A: Because it fouls the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    CBFalconer, May 2, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dietrich
    Replies:
    1
    Views:
    656
    Joe Smith
    Jul 22, 2004
  2. Leon
    Replies:
    2
    Views:
    542
  3. =?ISO-8859-1?Q?KLEIN_St=E9phane?=
    Replies:
    3
    Views:
    461
    hanumizzle
    Oct 6, 2006
  4. Replies:
    10
    Views:
    717
    Chris Torek
    Feb 4, 2005
  5. jimjim
    Replies:
    16
    Views:
    852
    Jordan Abel
    Mar 28, 2006
Loading...

Share This Page