X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=include%2Fatalk%2Futil.h;h=94aab1af3d0ef7aa710ac58e0f0165301bd95302;hb=071887b8a84c7111477d9e1fcc8be9ea2b0c47e5;hp=386b6c28c9b1c1ddfb8560752e66480595788627;hpb=130d356c840ea83c31c4724c8ae92660360eb07b;p=netatalk.git diff --git a/include/atalk/util.h b/include/atalk/util.h index 386b6c28..94aab1af 100644 --- a/include/atalk/util.h +++ b/include/atalk/util.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,7 @@ #define EXITERR_CLNT 1 /* client related error */ #define EXITERR_CONF 2 /* error in config files/cmd line parameters */ #define EXITERR_SYS 3 /* local system error */ +#define EXITERR_CLOSED 4 /* connection was immediately closed after TCP handshake */ /* Print a SBT and exit */ #define AFP_PANIC(why) \ @@ -72,6 +74,10 @@ #define ntoh64(x) (hton64(x)) #endif +#ifndef SAFE_FREE +#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) +#endif + #ifdef WITH_SENDFILE extern ssize_t sys_sendfile (int __out_fd, int __in_fd, off_t *__offset,size_t __count); #endif @@ -125,6 +131,10 @@ extern void *mod_symbol (void *, const char *); #define mod_close(a) dlclose(a) #endif /* ! HAVE_DLFCN_H */ +#ifndef strequal +#define strequal(a,b) (strcmp((a),(b)) == 0) +#endif + /****************************************************************** * locking.c ******************************************************************/ @@ -151,26 +161,32 @@ extern int compare_ip(const struct sockaddr *sa1, const struct sockaddr *sa2); extern int tokenize_ip_port(const char *ipurl, char **address, char **port); /* Structures and functions dealing with dynamic pollfd arrays */ -enum fdtype {IPC_FD, LISTEN_FD}; -struct polldata { - enum fdtype fdtype; /* IPC fd or listening socket fd */ - void *data; /* pointer to AFPconfig for listening socket and * - * pointer to afp_child_t for IPC fd */ + +enum asev_fdtype {IPC_FD, LISTEN_FD}; + +/** + * atalk socket event data + **/ +struct asev_data { + enum asev_fdtype fdtype; /* IPC fd or listening socket fd */ + void *private; /* pointer to AFPconfig for listening socket and * + * pointer to afp_child_t for IPC fd */ +}; + +/** + * atalk socket event + **/ +struct asev { + struct pollfd *fdset; /* struct pollfd array for poll() */ + struct asev_data *data; /* associated array of data */ + int max; + int used; }; -extern void fdset_add_fd(int maxconns, - struct pollfd **fdsetp, - struct polldata **polldatap, - int *fdset_usedp, - int *fdset_sizep, - int fd, - enum fdtype fdtype, - void *data); -extern void fdset_del_fd(struct pollfd **fdsetp, - struct polldata **polldatap, - int *fdset_usedp, - int *fdset_sizep, - int fd); +extern struct asev *asev_init(int max); +extern bool asev_add_fd(struct asev *sev, int fd, enum asev_fdtype fdtype, void *private); +extern bool asev_del_fd(struct asev *sev, int fd); + extern int send_fd(int socket, int fd); extern int recv_fd(int fd, int nonblocking);