e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. */
fccd4c1998-03-28Henrik Grubbström (Grubba) 
5267b71995-08-09Fredrik Hübinette (Hubbe) #ifndef FILE_H #define FILE_H
6283791995-09-01Fredrik Hübinette (Hubbe) #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif #ifdef HAVE_ARPA_INET_H #ifndef ARPA_INET_H #include <arpa/inet.h> #define ARPA_INET_H
cb22561995-10-11Fredrik Hübinette (Hubbe)  /* Stupid patch to avoid trouble with Linux includes... */ #ifdef LITTLE_ENDIAN #undef LITTLE_ENDIAN #endif
6283791995-09-01Fredrik Hübinette (Hubbe) #endif #endif
486dbe2003-04-23Marcus Comstedt #include "pike_netlib.h"
10dac82004-04-05Martin Stjernholm #include "backend.h"
486dbe2003-04-23Marcus Comstedt 
f171a72013-10-16Henrik Grubbström (Grubba) #if defined(HAVE_IPPROTO_IPv6) && !defined(IPPROTO_IPV6) // Hidden in an enum. #define IPPROTO_IPV6 IPPROTO_IPV6 #endif
849f1c1995-11-15David Hedbor struct my_file
5267b71995-08-09Fredrik Hübinette (Hubbe) {
10dac82004-04-05Martin Stjernholm  struct fd_callback_box box; /* Must be first. */ /* The box is hooked in whenever box.backend is set. */
ca6bd02012-05-01Bill Welliver  struct svalue event_cbs[6];
10dac82004-04-05Martin Stjernholm  /* Callbacks can be set without having the corresponding bits in * box.events, but not the other way around. */
f0d73c1995-11-04Fredrik Hübinette (Hubbe)  short open_mode;
a1ef721998-04-05Fredrik Hübinette (Hubbe)  short flags; int my_errno;
f126b62010-11-19Henrik Grubbström (Grubba) #ifdef HAVE_PIKE_SEND_FD int *fd_info; /* Info about fds pending to be sent. * If non-NULL the first element is the array size, * and the second is the number of fds pending to be * sent. Elements three and onwards are fds to send. * * Note that to avoid races between the call to * send_fd() and the call to write(), these fds * are dup(2)'ed in send_fd() and close(2)'ed after * sending in write() (or close() or destroy()). */ #endif
10dac82004-04-05Martin Stjernholm #if defined(HAVE_FD_FLOCK) || defined(HAVE_FD_LOCKF)
d386e61998-03-20Fredrik Hübinette (Hubbe)  struct object *key; #endif
5267b71995-08-09Fredrik Hübinette (Hubbe) };
023e682000-01-27Henrik Grubbström (Grubba) #ifdef _REENTRANT struct pike_sendfile { struct object *self; struct array *headers; struct array *trailers; struct object *from_file; struct object *to_file;
f33d082003-06-02Martin Stjernholm  struct callback *backend_callback;
023e682000-01-27Henrik Grubbström (Grubba)  struct svalue callback; struct array *args; int from_fd; int to_fd; struct my_file *from; struct my_file *to;
67dca22010-02-24Henrik Grubbström (Grubba)  LONGEST sent;
7a4ca62003-12-08Henrik Grubbström (Grubba)  LONGEST offset; LONGEST len;
023e682000-01-27Henrik Grubbström (Grubba)  struct iovec *hd_iov; struct iovec *tr_iov; int hd_cnt; int tr_cnt; struct iovec *iovs; char *buffer;
b96ca92000-08-19Henrik Grubbström (Grubba)  ptrdiff_t buf_size;
023e682000-01-27Henrik Grubbström (Grubba) }; #endif /* _REENTRANT */
61e49f1999-04-20Henrik Grubbström (Grubba) extern struct program *file_program; extern struct program *file_ref_program;
410f842012-01-25Henrik Grubbström (Grubba) /* Note: Implemented in ../system/system.c! */ extern int get_inet_addr(PIKE_SOCKADDR *addr,char *name,char *service, INT_TYPE port, int inet_flags); #define PIKE_INET_FLAG_UDP 1 #define PIKE_INET_FLAG_IPV6 2
bdd6e92012-01-25Henrik Grubbström (Grubba) #define PIKE_INET_FLAG_NB 4
dfa0b61997-01-21Fredrik Hübinette (Hubbe) 
01a9572000-02-03Henrik Grubbström (Grubba) #ifdef _REENTRANT
023e682000-01-27Henrik Grubbström (Grubba) void low_do_sendfile(struct pike_sendfile *);
01a9572000-02-03Henrik Grubbström (Grubba) #endif /* _REENTRANT */
023e682000-01-27Henrik Grubbström (Grubba) 
5267b71995-08-09Fredrik Hübinette (Hubbe) /* Prototypes begin here */
c657d01997-01-29Fredrik Hübinette (Hubbe) void my_set_close_on_exec(int fd, int to);
be478c1997-08-30Henrik Grubbström (Grubba) void do_set_close_on_exec(void);
10dac82004-04-05Martin Stjernholm 
29f9a92013-06-11Martin Nilsson void init_stdio_efuns(void); void exit_stdio_efuns(void); void init_stdio_stat(void); void exit_stdio_stat(void); void init_stdio_port(void); void exit_stdio_port(void); void init_stdio_sendfile(void); void exit_stdio_sendfile(void); void init_stdio_udp(void); void exit_stdio_udp(void);
d325652006-07-05Martin Stjernholm PMOD_EXPORT struct object *file_make_object_from_fd(int fd, int mode, int guess);
9821782009-02-23Henrik Grubbström (Grubba) PMOD_EXPORT void push_new_fd_object(int factory_fun_num, int fd, int mode, int guess);
bcf9461998-01-27Fredrik Hübinette (Hubbe) int my_socketpair(int family, int type, int protocol, int sv[2]);
a1ef721998-04-05Fredrik Hübinette (Hubbe) int socketpair_ultra(int family, int type, int protocol, int sv[2]); struct new_thread_data; void file_proxy(INT32 args);
d325652006-07-05Martin Stjernholm PMOD_EXPORT void create_proxy_pipe(struct object *o, int for_reading);
a1ef721998-04-05Fredrik Hübinette (Hubbe) struct file_lock_key_storage;
c657d01997-01-29Fredrik Hübinette (Hubbe) void mark_ids(struct callback *foo, void *bar, void *gazonk);
d325652006-07-05Martin Stjernholm PMOD_EXPORT int pike_make_pipe(int *fds); PMOD_EXPORT int fd_from_object(struct object *o);
6c1b012000-08-22Martin Stjernholm void f_strerror(INT32 args);
40962a2003-03-27Martin Stjernholm void push_stat(PIKE_STAT_T *s);
5267b71995-08-09Fredrik Hübinette (Hubbe) /* Prototypes end here */
16cc4e2004-11-09Martin Nilsson /* Defined by winnt.h */ #ifdef FILE_CREATE #undef FILE_CREATE #endif
11d4182003-07-03Henrik Grubbström (Grubba) /* open_mode *
300df82009-03-18Henrik Grubbström (Grubba)  * Note: The lowest 8 bits are reserved for the fd_* (aka PROP_*) * flags from "fdlib.h".
11d4182003-07-03Henrik Grubbström (Grubba)  */
bcf9461998-01-27Fredrik Hübinette (Hubbe) #define FILE_READ 0x1000 #define FILE_WRITE 0x2000 #define FILE_APPEND 0x4000 #define FILE_CREATE 0x8000
a1ef721998-04-05Fredrik Hübinette (Hubbe) 
bcf9461998-01-27Fredrik Hübinette (Hubbe) #define FILE_TRUNC 0x0100 #define FILE_EXCLUSIVE 0x0200 #define FILE_NONBLOCKING 0x0400 #define FILE_SET_CLOSE_ON_EXEC 0x0800
a1ef721998-04-05Fredrik Hübinette (Hubbe) /* flags */ #define FILE_NO_CLOSE_ON_DESTRUCT 0x0002
61e49f1999-04-20Henrik Grubbström (Grubba) #define FILE_LOCK_FD 0x0004
c9a7461999-09-29Mirar (Pontus Hagland) #define FILE_NOT_OPENED 0x0010
300df82009-03-18Henrik Grubbström (Grubba) #define FILE_HAVE_RECV_FD 0x0020
5267b71995-08-09Fredrik Hübinette (Hubbe)  #endif