Need help in understanding c code

Discussion in 'C Programming' started by Herman.Schultz@gmail.com, Jun 1, 2007.

  1. Guest

    Hi,

    I see this code in vlc code. I have a question about this line:
    net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
    "Range: bytes="I64Fd"-\r\n", i_tell );

    What is the meaning of "Range: bytes="I64Fd"-\r\n" ? especially I64Fd
    (in double quotes)


    static int Request( access_t *p_access, int64_t i_tell )
    {
    access_sys_t *p_sys = p_access->p_sys;
    char *psz ;
    v_socket_t *pvs = p_sys->p_vs;


    //.....

    net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
    "Range: bytes="I64Fd"-\r\n", i_tell );

    }
     
    , Jun 1, 2007
    #1
    1. Advertising

  2. said:

    > Hi,
    >
    > I see this code in vlc code. I have a question about this line:
    > net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
    > "Range: bytes="I64Fd"-\r\n", i_tell );
    >
    > What is the meaning of "Range: bytes="I64Fd"-\r\n" ? especially I64Fd
    > (in double quotes)


    It's probably a #define for "whatever the heck net_Printf uses as a
    format specifier for long long int". For example, it might be:

    #define I64Fd "%I64d"

    or it might be

    #define I64Fd "%lld"

    or something else.

    The string literal concatenation rule makes it all join up properly for
    the compiler.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Jun 1, 2007
    #2
    1. Advertising

  3. On Fri, 01 Jun 2007 14:14:47 -0000, wrote:

    >Hi,
    >
    >I see this code in vlc code. I have a question about this line:
    > net_Printf( VLC_OBJECT(p_access), p_sys->fd, pvs,
    > "Range: bytes="I64Fd"-\r\n", i_tell );
    >
    >What is the meaning of "Range: bytes="I64Fd"-\r\n" ? especially I64Fd
    >(in double quotes)
    >
    >

    I64Fd is not in double quotes. The expression consists of three
    parts:
    1 - the string literal "Range: bytes="
    2 - the "token" I64Fd
    3 - the string literal "-\r\n"

    As RH suggested, the token I64Fd is probably a #define that is set to
    some string literal (for sake of discussion, assume the literal is
    "%_"). Consequently, the entire expression consists of three string
    literals. When string literals abut or are separated only by white
    space, the compiler automatically concatenates them together. As a
    result, when the line question is compiled, the expression will the
    single string literal:
    "Range: bytes=%_-\r\n"

    As usual, the address of the literal will be the value passed to
    net_Printf.


    Remove del for email
     
    Barry Schwarz, Jun 2, 2007
    #3
    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. Replies:
    2
    Views:
    418
    Phlip
    Mar 15, 2007
  2. Daniel
    Replies:
    8
    Views:
    436
    Daniel
    Sep 13, 2007
  3. Replies:
    15
    Views:
    470
    Steven D'Aprano
    Nov 18, 2008
  4. Elmbrook

    need help understanding this code.

    Elmbrook, Sep 28, 2003, in forum: Javascript
    Replies:
    7
    Views:
    161
    Elmbrook
    Sep 29, 2003
  5. Ben
    Replies:
    6
    Views:
    112
    Tim McDaniel
    Apr 16, 2009
Loading...

Share This Page