/* IRCfs - IRC FileServ for *nix. * Copyright (C) 2002 Nick 'Zaf' Clifford * For licensing details, refer to the LICENSE file in the source * code directory. */ #ifndef __include_dccfile_h__ #define __include_dccfile_h__ #include "user.h" #include "event.h" #include "magic.h" #include "file.h" struct dccfile; enum dccfile_events { /* dccfile_event_pending * This event is raised when a file is being sent to us. * The event object sent is struct dccfile_pending_msg, and * not the normal dccfile_event_msg! * All fields are set to valid values except the reason field, * which the user should set to point to a non-stack buffer * containing the reason for denying the send. * The user can deny the send, by returning -1 instead of 0 from * the event handler */ dccfile_event_pending, /* dccfile_event_open * Occurs when a user starts recieving a file from us. * Once the dccfile object is created, the object sends out * a notice telling the user to connect to the socket. * Once the user has connected, this event is raised, and * the file is sent. * Valid fields: dccfile, who, and file. * Return value is ignored. */ dccfile_event_open, /* dccfile_event_close * Occurs when the dccfile object is detroyed. * Valid fields: dccfile, who, and file * Return value is ignored. */ dccfile_event_close, /* dccfile_event_finished * Occurs when the file is SUCCESSFULLY sent/recieved to/from the * user. * Valid fields: dccfile, who and file * Return value is ignored. */ dccfile_event_finished, /* dccfile_event_aborted * Occurs when the file transmission is aborted, eg not successfully * sent or recieved. * Valid fields: dccfile, who and file * Return value is ignored. */ dccfile_event_aborted }; #define MAGIC_DCCFILE_EVENT_MSG 0xA465B8DE struct dccfile_event_msg { MAGIC magic; struct dccfile *dccfile; struct user *who; struct file *file; }; #define MAGIC_DCCFILE_PENDING_MSG 0xA862F72A struct dccfile_pending_msg { MAGIC magic; const char *filename; size_t size; const char *ip; unsigned short port; struct user *who; struct dir *upload_dir; /* Set to the place to upload, NULL if use default */ char *reason; /* Set to the fail reason, if any */ }; struct dccfile_status { struct file *file; unsigned char percent; size_t total,so_far; time_t start; }; struct dccfile *dccfile_start_send(struct user *u, struct file *file); void dccfile_destroy(struct dccfile *df); struct eventobj *dccfile_get_event_obj(); struct dccfile_status *dccfile_get_status(struct dccfile *df); #endif