X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Finclude%2Fctdl_module.h;h=0287daa7be280d459bbc76e9d7704ee0a5ab81d8;hb=0b0f8a2280a8f22877baccd2355d7b41b863bfa0;hp=cba6917149cc81334444bea9abcc959f8cc0c837;hpb=c1b1936458ccd0d517148615a6ed753f6a3e30c2;p=citadel.git diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index cba691714..0287daa7b 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -1,13 +1,65 @@ -/* $Id$ */ #ifndef CTDL_MODULE_H #define CTDL_MODULE_H +#include "sysdep.h" + +#ifdef HAVE_GC +#define GC_THREADS +#define GC_REDIRECT_TO_LOCAL +#include +#else +#define GC_MALLOC malloc +#define GC_MALLOC_ATOMIC malloc +#define GC_FREE free +#define GC_REALLOC realloc +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif +#include + + +#ifndef HAVE_SNPRINTF +#include "snprintf.h" +#endif + + #include + #include "server.h" #include "sysdep_decls.h" #include "msgbase.h" #include "threads.h" +#include "citadel_dirs.h" +#include "context.h" + /* * define macros for module init stuff */ @@ -20,25 +72,60 @@ #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade () - -/* - * Prototype for making log entries in Citadel. - */ - -void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...); - -/* - * Fix the interface to aide_message so that it complies with the Coding style - */ - -#define CtdlAideMessage(TEXT, SUBJECT) aide_message(TEXT, SUBJECT) - +#define CtdlAideMessage(TEXT, SUBJECT) \ + quickie_message( \ + "Citadel", \ + NULL, \ + NULL, \ + AIDEROOM, \ + TEXT, \ + FMT_CITADEL, \ + SUBJECT) + + +#define CtdlAideFPMessage(TEXT, SUBJECT, N, STR, STRLEN) \ + flood_protect_quickie_message( \ + "Citadel", \ + NULL, \ + NULL, \ + AIDEROOM, \ + TEXT, \ + FMT_CITADEL, \ + SUBJECT, \ + N, \ + STR, \ + STRLEN) /* * Hook functions available to modules. */ - -void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType); +/* Priorities for */ +#define PRIO_QUEUE 500 +#define PRIO_AGGR 1000 +#define PRIO_SEND 1500 +#define PRIO_CLEANUP 2000 +/* Priorities for EVT_HOUSE */ +#define PRIO_HOUSE 3000 +/* Priorities for EVT_LOGIN */ +#define PRIO_CREATE 10000 +/* Priorities for EVT_LOGOUT */ +#define PRIO_LOGOUT 15000 +/* Priorities for EVT_LOGIN */ +#define PRIO_LOGIN 20000 +/* Priorities for EVT_START */ +#define PRIO_START 25000 +/* Priorities for EVT_STOP */ +#define PRIO_STOP 30000 +/* Priorities for EVT_ASYNC */ +#define PRIO_ASYNC 35000 +/* Priorities for EVT_SHUTDOWN */ +#define PRIO_SHUTDOWN 40000 +/* Priorities for EVT_UNSTEALTH */ +#define PRIO_UNSTEALTH 45000 +/* Priorities for EVT_STEALTH */ +#define PRIO_STEALTH 50000 +void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority); void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType); +void CtdlShutdownServiceHooks(void); void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); @@ -63,6 +150,9 @@ void CtdlUnregisterDeleteHook(void (*handler)(char *, long) ); void CtdlRegisterCleanupHook(void (*fcn_ptr)(void)); void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void)); +void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void)); +void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void)); + void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc); void CtdlRegisterServiceHook(int tcp_port, @@ -86,7 +176,7 @@ void CtdlUnRegisterFixedOutputHook(char *content_type); void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg)); -void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, char *), char *name); +void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name); /* @@ -108,37 +198,7 @@ int CtdlDoDirectoryServiceFunc(char *cn, char *ou, void **object, char *module, */ void CtdlModuleStartCryptoMsgs(char *ok_response, char *nosup_response, char *error_response); - -/* - * Citadel Threads API - */ -struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args); -struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when); -void CtdlThreadSleep(int secs); -void CtdlThreadStop(struct CtdlThreadNode *thread); -int CtdlThreadCheckStop(void); -/* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */ -const char *CtdlThreadName(const char *name); -struct CtdlThreadNode *CtdlThreadSelf(void); -int CtdlThreadGetCount(void); -int CtdlThreadGetWorkers(void); -double CtdlThreadGetWorkerAvg(void); -double CtdlThreadGetLoadAvg(void); -void CtdlThreadGC(void); -void CtdlThreadStopAll(void); -int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); -void CtdlThreadAllocTSD(void); - -#define CTDLTHREAD_BIGSTACK 0x0001 -#define CTDLTHREAD_WORKER 0x0002 - -/* Macros to speed up getting outr thread */ - -#define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors) -#define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid) -#define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self) - -/** return the current context list as an array and do it in a safe manner +/* return the current context list as an array and do it in a safe manner * The returned data is a copy so only reading is useful * The number of contexts is returned in count. * Beware, this does not copy any of the data pointed to by the context. @@ -147,13 +207,17 @@ void CtdlThreadAllocTSD(void); */ struct CitContext *CtdlGetContextArray (int *count); void CtdlFillSystemContext(struct CitContext *context, char *name); - int CtdlTrySingleUser(void); void CtdlEndSingleUser(void); int CtdlWantSingleUser(void); int CtdlIsSingleUser(void); +int CtdlIsUserLoggedIn (char *user_name); +int CtdlIsUserLoggedInByNum (long usernum); +void CtdlBumpNewMailCounter(long which_user); + + /* * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system * This provides a quick way to initialise a variable that might be used to indicate @@ -192,6 +256,10 @@ struct floor *CtdlGetCachedFloor(int floor_num); void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf); void CtdlGetFloor (struct floor *flbuf, int floor_num); void CtdlPutFloor (struct floor *flbuf, int floor_num); +void CtdlPutFloorLock(struct floor *flbuf, int floor_num); +int CtdlGetFloorByName(const char *floor_name); +int CtdlGetFloorByNameLock(const char *floor_name); +int CtdlGetAvailableFloor(void); int CtdlIsNonEditable(struct ctdlroom *qrbuf); void CtdlPutRoom(struct ctdlroom *); @@ -207,4 +275,175 @@ enum { crr_access_denied /* not allowed to edit this room */ }; + + +/* + * API declarations from citserver.h + */ +int CtdlAccessCheck(int); +/* 'required access level' values which may be passed to CtdlAccessCheck() + */ +enum { + ac_none, + ac_logged_in_or_guest, + ac_logged_in, + ac_room_aide, + ac_aide, + ac_internal, +}; + + + +/* + * API declarations from serv_extensions.h + */ +void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name); + +/* + * Global system configuration + */ +struct config { + char c_nodename[16]; /* short name of this node on a Citadel network */ + char c_fqdn[64]; /* this site's fully qualified domain name */ + char c_humannode[21]; /* human-readable site name */ + char c_phonenum[16]; /* telephone number */ + uid_t c_ctdluid; /* uid of posix account under which Citadel will run */ + char c_creataide; /* 1 = creating a room auto-grants room aide privileges */ + int c_sleeping; /* watchdog timer (seconds) */ + char c_initax; /* initial access level for new users */ + char c_regiscall; /* after c_regiscall logins user will be asked to register */ + char c_twitdetect; /* automatically move messages from problem users to trashcan */ + char c_twitroom[ROOMNAMELEN]; /* name of trashcan */ + char c_moreprompt[80]; /* paginator prompt */ + char c_restrict; /* require per-user permission to send Internet mail */ + long c_niu_1; + char c_site_location[32]; /* geographic location of this Citadel site */ + char c_sysadm[26]; /* name of system administrator */ + char c_niu_2[15]; + int c_niu_3; + int c_maxsessions; /* maximum number of concurrent sessions allowed */ + char c_ip_addr[20]; /* bind address for listening sockets */ + int c_port_number; /* port number for Citadel protocol (usually 504) */ + int c_niu_4; + struct ExpirePolicy c_ep; /* default expire policy for the entire site */ + int c_userpurge; /* user purge time (in days) */ + int c_roompurge; /* room purge time (in days) */ + char c_logpages[ROOMNAMELEN]; + char c_createax; + long c_maxmsglen; + int c_min_workers; + int c_max_workers; + int c_pop3_port; + int c_smtp_port; + int c_rfc822_strict_from; + int c_aide_zap; + int c_imap_port; + time_t c_net_freq; + char c_disable_newu; + char c_enable_fulltext; + char c_baseroom[ROOMNAMELEN]; + char c_aideroom[ROOMNAMELEN]; + int c_purge_hour; + struct ExpirePolicy c_mbxep; + char c_ldap_host[128]; + int c_ldap_port; + char c_ldap_base_dn[256]; + char c_ldap_bind_dn[256]; + char c_ldap_bind_pw[256]; + int c_msa_port; + int c_imaps_port; + int c_pop3s_port; + int c_smtps_port; + char c_auto_cull; + char c_instant_expunge; + char c_allow_spoofing; + char c_journal_email; + char c_journal_pubmsgs; + char c_journal_dest[128]; + char c_default_cal_zone[128]; + int c_pftcpdict_port; + int c_managesieve_port; + int c_auth_mode; + char c_funambol_host[256]; + int c_funambol_port; + char c_funambol_source[256]; + char c_funambol_auth[256]; + char c_rbl_at_greeting; + char c_master_user[32]; + char c_master_pass[32]; + char c_pager_program[256]; + char c_imap_keep_from; + int c_xmpp_c2s_port; + int c_xmpp_s2s_port; + time_t c_pop3_fetch; + time_t c_pop3_fastest; + int c_spam_flag_only; + int c_guest_logins; +}; + +extern struct config config; + + + +/* + * Expose API calls from user_ops.c + */ +int CtdlGetUser(struct ctdluser *usbuf, char *name); +int CtdlGetUserLen(struct ctdluser *usbuf, const char *name, long len); +int CtdlGetUserLock(struct ctdluser *usbuf, char *name); +void CtdlPutUser(struct ctdluser *usbuf); +void CtdlPutUserLock(struct ctdluser *usbuf); +int CtdlGetUserByNumber(struct ctdluser *usbuf, long number); +void CtdlGetRelationship(visit *vbuf, + struct ctdluser *rel_user, + struct ctdlroom *rel_room); +void CtdlSetRelationship(visit *newvisit, + struct ctdluser *rel_user, + struct ctdlroom *rel_room); +void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix); + +int CtdlLoginExistingUser(char *authname, const char *username); + +/* + * Values which may be returned by CtdlLoginExistingUser() + */ +enum { + pass_ok, + pass_already_logged_in, + pass_no_user, + pass_internal_error, + pass_wrong_password +}; + +int CtdlTryPassword(const char *password, long len); +/* + * Values which may be returned by CtdlTryPassword() + */ +enum { + login_ok, + login_already_logged_in, + login_too_many_users, + login_not_found +}; + +void CtdlUserLogout(void); + + + + +/* + * Expose API calls from msgbase.c + */ +char *CtdlGetSysConfig(char *sysconfname); +void CtdlPutSysConfig(char *sysconfname, char *sysconfdata); + + + + +/* + * Expose API calls from euidindex.c + */ +long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf); + + #endif /* CTDL_MODULE_H */