pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:4925:    ERRNO = errno = ENOTTY;   #else /* !ENOTTY */    ERRNO = errno = EIO;   #endif /* ENOTTY */   #endif /* ENOTSUP */   #endif /* SO_KEEPALIVE */    pop_n_elems(args);    push_int(!i);   }    - /*! @decl int(0..1) setsockopt(int opt,int(0..1) on_off) + /*! @decl int(0..1) setsockopt(int level,int opt,int state)    *!    *! Set socket options like Stdio.SO_KEEPALIVE. This function is always    *! available; the presence or absence of the option constants indicates    *! availability of those features.    *!    *! @returns    *! 1 if successful, 0 if not (and sets errno())    *!    *! @seealso    *! @[set_keepalive()]    */   static void file_setsockopt(INT32 args)   { -  int tmp, i, opt; -  INT_TYPE o, t; +  int tmp, i, opt, level; +  INT_TYPE o, t, l;    -  get_all_args("setsockopt", args, "%i%i", &o, &t); +  get_all_args("setsockopt", args, "%i%i%i", &l, &o, &t);       /* In case int and INT_TYPE have different sizes */ -  tmp = t; opt = o; +  tmp = t; opt = o; level = l;    -  i = fd_setsockopt(FD, SOL_SOCKET, opt, (char *)&tmp, sizeof(tmp)); +  i = fd_setsockopt(FD, level, opt, (char *)&tmp, sizeof(tmp));    if(i)    {    ERRNO=errno;    }else{    ERRNO=0;    }    pop_n_elems(args);    push_int(!i);   }   
pike.git/src/modules/_Stdio/file.c:6291:    };    add_string_constant( "SEEK_CUR", seek_how+0, 0 );    add_string_constant( "SEEK_SET", seek_how+2, 0 );    add_string_constant( "SEEK_END", seek_how+4, 0 );   #ifdef SEEK_DATA    add_string_constant( "SEEK_DATA", seek_how+6, 0 );    add_string_constant( "SEEK_HOLE", seek_how+8, 0 );   #endif    };    + #ifdef SOL_SOCKET +  /*! @decl constant SOL_SOCKET +  *! Used in @[File.setsockopt()] to set socket-level options +  */ +  add_integer_constant("SOL_SOCKET", SOL_SOCKET, 0); + #endif +  + #ifdef IPPROTO_IP +  /*! @decl constant IPPROTO_IP +  *! Used in @[File.setsockopt()] to set IP-level options +  */ +  add_integer_constant("IPPROTO_IP", IPPROTO_IP, 0); + #endif +  + #ifdef IPPROTO_TCP +  /*! @decl constant IPPROTO_TCP +  *! Used in @[File.setsockopt()] to set TCP-level options +  */ +  add_integer_constant("IPPROTO_TCP", IPPROTO_TCP, 0); + #endif +    #ifdef TCP_NODELAY    /*! @decl constant TCP_NODELAY    *! Used in @[File.setsockopt()] to control Nagle's Algorithm.    */    add_integer_constant("TCP_NODELAY", TCP_NODELAY, 0);   #endif      #ifdef SO_KEEPALIVE    /*! @decl constant SO_KEEPALIVE    *! Used in @[File.setsockopt()] to control TCP/IP keep-alive packets.    */    add_integer_constant("SO_KEEPALIVE", SO_KEEPALIVE, 0);   #endif    -  + #ifdef IP_TOS +  /*! @decl constant IP_TOS +  *! Used in @[File.setsockopt()] to set Type Of Service +  */ +  add_integer_constant("IP_TOS", IP_TOS, 0); + #endif +     add_integer_constant("__HAVE_OOB__",1,0);   #ifdef PIKE_OOB_WORKS    add_integer_constant("__OOB__",PIKE_OOB_WORKS,0);   #else    add_integer_constant("__OOB__",-1,0); /* unknown */   #endif      #ifdef HAVE_SYS_UN_H    add_integer_constant("__HAVE_CONNECT_UNIX__",1,0);   #endif