/* ARISA - Primary Data Structures */ /* Copyright (C) 2003 Carl Ritson */ #define _ARISA_STRUCTS_H /* NOTE: Comments that begin with a dash are flags for the loadsave script. */ enum pformat_t { PFORMAT_MINIMAL, PFORMAT_SUMMARY, PFORMAT_FULL, PFORMAT_TAGONLY }; enum networkstate_t { NETWORK_OFFLINE, // Offline means no thread NETWORK_RUNNING, // Running means there is a thread NETWORK_CONNECTING, // Thread is connecting NETWORK_LOGIN, // Thread at login stage NETWORK_CONNECTED // Thread is running and is connected }; enum state_t { STATE_UNKNOWN, // when new STATE_QUEUED, // while queued STATE_RESOLVING, // when resolving, for admin/upload/dccserver STATE_CONNECTING, // when connecting, for upload/dccserver STATE_NEGOTIATING, // during dccserver negotiation STATE_LISTENING, // listening for normal dcc send STATE_ACTIVE, // active send/upload/chat STATE_COMPLETING, // send in final acknoledgement phase STATE_COMPLETE, // completed send/upload STATE_SLOW, // send below minimum speed requirement STATE_TIMEOUT, // send/upload/chat which has timed out STATE_DELETED, // deleted send/upload/chat STATE_PURGING, // internal deletion state for send/upload/chat STATE_PURGEREQUEUE, // if send can be requeued, requeue else purge STATE_ERROR, // send/upload/chat closed due to socket error STATE_RETRY, // send in retry state, for dccserver STATE_RESUME, // send/upload received or pending a resume msg STATE_RESUMED // upload, when resume msg has been receieved }; enum listtype_t { LIST_NORMAL = 0, // = 0 for legacy LIST_NOPACKS, LIST_TAGONLY, LIST_CHAT }; enum responsetype_t { RESPONSE_NOTICE, RESPONSE_PRIVMSG }; enum chattype_t { CHAT_ADMIN, CHAT_LIST }; enum colourtype_t { COLOUR_NONE, COLOUR_IRC, COLOUR_INT }; enum interfacetype_t { INTERFACE_SEND, INTERFACE_RECV, INTERFACE_CHAT }; enum interfacemode_t { IMODE_DCCSERVER, IMODE_NORMAL, IMODE_REVERSE }; enum sorttype_t { SORT_NONE = 0, SORT_AZ = 1, SORT_ZA = 2, SORT_I_AZ = 3, SORT_I_ZA = 4 }; enum hashtype_t { HASH_NONE, HASH_CRC, HASH_MD5, HASH_CRC_AND_MD5 }; struct netset_t { /*-C*/ char *nick; /*-C*/ char *loginname; /*-C*/ char *realname; float message_rate; int message_rate_max; int recv_per_sec; int average_window; int max_target; int irc_timeout; int on_connect_delay; int join_delay; int reconnect_delay; int no_autoconnect; int nick_tracking; char *bind_ip; char *info_line; char **taglines; /*-!*/ int no_taglines; }; struct channel_t { /*-L*/ lock_t lock; time_t deleted; /*-C*/ char *name; char *key; /*-!*/ time_t joined; // flag indicates we have joined this channel time_t nolist; int plist; int track_key; pformat_t pformat; /*-!*/ time_t last_plist; char **taglines; /*-!*/ int no_taglines; /*-!*/ pqueue_t **listeners; /*-!*/ int no_listeners; /* runtime data on the state of the channel, only for scripts */ /*-!*/ char *mode; /*-!*/ char *topic; /*-!*/ int limit; /*-!*/ char **bans; /*-!*/ int no_bans; }; struct netinfo_t /*-!*/ { lock_t lock; char *nick; char *server; char *password; uint32_t self_ip; uint16_t port; pqueue_t p_squeue; /* Priority */ pqueue_t j_squeue; /* Join */ pqueue_t d_squeue; /* DCC */ pqueue_t r_squeue; /* Regular */ nickhash_t *nick_tracker; time_t connected; }; struct network_t /*-i NULL*/ { /*-L*/ lock_t lock; time_t deleted; /*-!*/ thread_t thread; /*-C*/ char *name; /*-!*/ netinfo_t *info; /*-!*/ networkstate_t state; char **servers; /*-!*/ int no_servers; channel_t **channels; /*-!*/ int no_channels; char **on_connects; /*-!*/ int no_on_connects; netset_t *settings; /*-!*/ pqueue_t **listeners; /*-!*/ int no_listeners; }; struct pack_t { /*-L*/ rwlock_t lock; /*-R*/ int ref_count; off_t size; /*-C*/ char *file; char *label; char *md5; char *crc; time_t hashed; int no_gets; // Pack Cache Fields /*-!*/ pack_t *next; /*-!*/ pack_t *prev; /*-!*/ uint32_t hash; }; struct send_t { /*-L*/ lock_t lock; /*-C*/ pack_t *pack; char *host; /*-C*/ char *nick; /*-C>*/ network_t *network; /*-!*/ state_t state; /*->*/ pool_t *pool; // maintained for the benefit of // functions view the send without // context to know the pool /*->*/ queue_t *queue; // used only by sends, to track queue int retries; // number of remaining retries time_t started; // When queued this is when the send // started queue'ing else when the // DCC SEND msg was sent. time_t connected; time_t last_contact; /*-!*/ uint32_t avgspeed[AVGSPEED]; /*-!*/ off_t pos; /*-!*/ off_t bytes_sent; char *reason; // when an admin cancels the send // send this reason to client (if set) /*-!*/ void *aux; // context sensitive auxillary info // see dcc.h for specific structs }; struct interface_t { /*-L*/ lock_t lock; time_t deleted; /*-!*/ thread_t thread; /*-C*/ char *name; /*-i0*/ interfacetype_t type; /*-i0*/ interfacemode_t mode; int def; // is default for its type unsigned int bandwidth; unsigned int snd_bufsize; unsigned int rcv_bufsize; char *advertise_ip; char *bind_ip; int accept_per_sec; int secure_mode; unsigned int dcc_port; unsigned int no_ports; unsigned int dccserver_port; unsigned int dcc_timeout; unsigned int dcc_packet; /* stats */ uint32_t record_rate; uint32_t stat_mib; uint32_t stat_carry; /*-!*/ uint32_t avgspeed[AVGSPEED]; union { struct /*-? type==INTERFACE_SEND*/ { pool_t **pools; /*-!*/ int no_pools; } send; struct /*-? type==INTERFACE_RECV*/ { char *dir; /*-f*/ access_t *access; /*-!*/ send_t **uploads; /*-!*/ int no_uploads; int max_no_uploads; off_t max_size; } recv; struct /*-? type==INTERFACE_CHAT*/ { int max_no; // maximum number of chats /*-!*/ chat_t **chats; /*-!*/ int no_chats; } chat; }; }; struct pool_t { /*-L*/ lock_t lock; time_t deleted; /*-!*/ int state; /*-C*/ char *name; send_t **csends; /*-!*/ int no_csends; /*-!*/ uint32_t avgspeed[AVGSPEED]; unsigned int sends; unsigned int bandwidth; unsigned int send_max_bandwidth; unsigned int send_min_bandwidth; int sends_per_user; int dequeue_algorithm; uint32_t record_send; uint32_t record_rate; uint32_t stat_mib; uint32_t stat_carry; }; struct queue_t { /*-L*/ lock_t lock; time_t deleted; /*-C*/ char *name; /*-C>*/ pool_t *pool; send_t **qsends; /*-!*/ int no_qsends; int length; int notify; int queues_per_user; int overflow_requeue; int combined_queue_limit; int priority; int priority_queues; off_t bypass_size; time_t last_notify; time_t last_dequeue; time_t last_checked; }; struct packlist_t { /*-L*/ lock_t lock; time_t deleted; /*-C*/ char *name; listtype_t type; responsetype_t response; /*->*/ interface_t *chat_interface; // for chat type lists, can be NULL /*-C>*/ queue_t *queue; pack_t **packs; /*-!*/ int no_packs; char **dirs; /*-!*/ int no_dirs; int time_limit; int command_limit; int retries; sorttype_t auto_sort; hashtype_t hash_display; uint32_t dir_scan_interval; int scan_depth; time_t last_scan; time_t nolist; char *nolist_reason; time_t nosend; char *nosend_reason; /*-f*/ access_t *access; char **taglines; /*-!*/ int no_taglines; /*-f*/ ignore_list_t *ignore_list; char **filters; int no_filters; }; struct user_t /*-i NULL*/ { /*-L*/ lock_t lock; time_t deleted; /*-C*/ char *username; char *password; char **hosts; /*-!*/ int no_hosts; char **dirs; /*-!*/ int no_dirs; /*->*/ packlist_t **packlists; /*-!*/ int no_packlists; int no_permitted_logons; char *privs; /*-!*/ uint32_t uprivs; time_t last_logon; }; struct chat_t /*-!*/ { /* fields common to all chat types */ lock_t lock; chattype_t type; colourtype_t colour; state_t state; char *nick; network_t *network; char *host; char *hostmask; pqueue_t msgqueue; time_t started; time_t connected; time_t last_contact; char *reason; // serves the same function as send_t->reason void *aux; union { /* data used by list type chats */ struct { int commands; /* no commands executed */ packlist_t *packlist; } list; /* data used by admin type chats */ struct { thread_t thread; user_t *user; } admin; }; }; struct settings_t { /*-L*/ lock_t lock; /*-!*/ char *config; char *pid; char *log; char *admin_socket; int hash_packs; int list_frequency; int log_interval; int autosave_interval; int tick_interval; int hashing_io_usage; char **scripts; /*-!*/ int no_scripts; }; struct interpreter_t /*-!*/ { lock_t lock; thread_t thread; char *name; void *(*func)(void *); int flags; pqueue_t msgqueue; char **loaded; int no_loaded; char **types; int no_types; }; struct access_entry_t { int flags; int mode; /*->*/ network_t *network; /*->*/ channel_t *channel; char *host; }; struct access_t { /*-L*/ lock_t lock; int flags; access_entry_t **entries; /*-!*/ int no_entries; }; struct ignore_entry_t { int flags; /*-C*/ char *mask; time_t expires; }; struct ignore_list_t { /*-L*/ lock_t lock; time_t last_prune; int period; int trigger; int log; ignore_entry_t **entries; /*-!*/ int no_entries; /*-!*/ void *data; }; struct global_t { /*-L*/ lock_t lock; /*-!*/ volatile int end; /*-!*/ time_t end_time; /*-!*/ int signal_in; /*-!*/ int signal_out; /* thread data */ /*-!*/ thread_t hash_thread; /*-!*/ thread_t log_thread; /* global dynamic data */ /*-!*/ aresolv_t *aresolver; /*-f*/ ignore_list_t *ignore_list; /*-!*/ pack_cache_t *pack_cache; /* sub settings structures */ /*-Cf*/ settings_t *settings; /*-Cf*/ netset_t *network_settings; /* arrays of data structures */ network_t **networks; /*-!*/ int no_networks; interface_t **interfaces; /*-!*/ int no_interfaces; queue_t **queues; /*-!*/ int no_queues; packlist_t **packlists; /*-!*/ int no_packlists; user_t **users; /*-!*/ int no_users; /*-!*/ chat_t **admins; /* active admin chats */ /*-!*/ int no_admins; /* logging */ /*-!*/ struct { lock_t lock; pqueue_t **subs; int no_subs; int fd; } log_subs; /* hashing */ /*-!*/ struct { lock_t lock; pqueue_t *reqs; } hashing; /* party line */ /*-!*/ struct { lock_t lock; pqueue_t **subs; int no_subs; } party_line; /* scripting engines */ /*-!*/ struct { lock_t lock; interpreter_t **interpreters; int no_interpreters; } se; };