]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/chanserv.h
fix bug in G stats
[irc/quakenet/newserv.git] / chanserv / chanserv.h
index 693f0643b7f92d4b73eeb2ca4af74d6a2788762a..745356dda1c7bc4cde02fa7230bac6590eb7d09f 100644 (file)
@@ -11,6 +11,8 @@
 #include <string.h>
 #include <time.h>
 #include <stdarg.h>
+#include <stdint.h>
+
 #include "../lib/sstring.h"
 #include "../core/schedule.h"
 #include "../lib/flags.h"
 #include "../channel/channel.h"
 #include "../parser/parser.h"
 #include "../localuser/localuserchannel.h"
-#include "../pqsql/pqsql.h"
+
+#ifndef CS_NODB
+#include "../dbapi/dbapi.h"
+#endif
 
 #define CS_PARANOID
 
@@ -27,7 +32,7 @@
 #endif
 
 /* Q9 Version */
-#define QVERSION "1.00-RC2"
+#define QVERSION "1.00"
 
 /* Mini-hash of known users on channels to make lookups faster;
  * how big do we make it?  */
 #define   MAXSUSPENDHIT       500
 
 /* Maximum number of times a user may attempt to auth */
-#define   MAXAUTHATTEMPT      5
+#define   MAXAUTHATTEMPT      10
 
 /* Maximum number of hellos in a session */
-#define   MAXHELLOS           3
+#define   MAXHELLOS           2
 
 /* Maximum number of times a user may actually be authed */
 #define   MAXAUTHCOUNT        2
 /* If set will issue warnings when authgate cached stuff changes */
 #define   AUTHGATE_WARNINGS
 
+/* Challenge auth faq site */
+#define   CHALLENGEAUTHSITE "http://www.quakenet.org/development/challengeauth/"
+
 /* Cleanup options */
 #define CLEANUP_ACCOUNT_INACTIVE  80
 #define CLEANUP_ACCOUNT_UNUSED    10
-#define CLEANUP_CHANNEL_INACTIVE  30
+#define CLEANUP_CHANNEL_INACTIVE  40
 
 /* Sizes of the main hashes */
 #define   REGUSERHASHSIZE     60000
 #define MAXLANG      50
 
 /* Maximum number of user chanlevs and bans */
-#define MAXCHANLEVS  250
+#define MAXCHANLEVS  500
 #define MAXBANS      50
 
 /* Sources of entropy and standard length defines */
 #define ENTROPYSOURCE "/dev/urandom"
 #define ENTROPYLEN    8
 
+/* Minimum acceptable reason length for stuff like deluser */
+#define MIN_REASONLEN 20
+
 #include "chanserv_messages.h"
 
+#define CSMIN(a, b) ((a)<(b)?(a):(b))
+#define CSMAX(a, b) ((a)>(b)?(a):(b))
+
 /* List of privileged operations */
 
 #define   QPRIV_SUSPENDBYPASS       1
 #define   QPRIV_VIEWWELCOME         107
 #define   QPRIV_VIEWCOMMENTS        108
 #define   QPRIV_VIEWEMAIL           109
+#define   QPRIV_VIEWCHANSUSPENSION  110
+#define   QPRIV_VIEWSUSPENDEDBY     111
+#define   QPRIV_VIEWWALLMESSAGE     112
 
 #define   QPRIV_CHANGECHANFLAGS     200
 #define   QPRIV_CHANGECHANLEV       201
 #define   QUFLAG_NOINFO        0x0001  /* +s */
 #define   QUFLAG_GLINE         0x0002  /* +g */
 #define   QUFLAG_NOTICE        0x0004  /* +n */
-/* SPARE FLAG                  0x0008 */
+#define   QUFLAG_STAFF         0x0008  /* +q */
 #define   QUFLAG_SUSPENDED     0x0010  /* +z */
 #define   QUFLAG_OPER          0x0020  /* +o */
 #define   QUFLAG_DEV           0x0040  /* +d */
 #define   QUFLAG_NOAUTHLIMIT   0x1000  /* +L */
 #define   QUFLAG_CLEANUPEXEMPT 0x4000  /* +D */
 #define   QUFLAG_TRUST         0x8000  /* +T */
-#define   QUFLAG_ALL           0xdff7
+#define   QUFLAG_ALL           0xdfff
 
 #define UIsNoInfo(x)        ((x)->flags & QUFLAG_NOINFO)
 #define UIsGline(x)         ((x)->flags & QUFLAG_GLINE)
 #define UIsDelayedGline(x)  ((x)->flags & QUFLAG_DELAYEDGLINE)
 #define UIsNoAuthLimit(x)   ((x)->flags & QUFLAG_NOAUTHLIMIT)
 #define UIsCleanupExempt(x) ((x)->flags & QUFLAG_CLEANUPEXEMPT)
+#define UIsStaff(x)         ((x)->flags & QUFLAG_STAFF)
 
 #define UHasSuspension(x)   ((x)->flags & (QUFLAG_GLINE|QUFLAG_DELAYEDGLINE|QUFLAG_SUSPENDED))
 
+#define UHasStaffPriv(x)    ((x)->flags & (QUFLAG_STAFF | QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
 #define UHasHelperPriv(x)   ((x)->flags & (QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
 #define UHasOperPriv(x)     ((x)->flags & (QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
 #define UHasAdminPriv(x)    ((x)->flags & (QUFLAG_ADMIN | QUFLAG_DEV))
 #define   QCMD_OPER           0x0020 /* Only available to opers */
 #define   QCMD_ADMIN          0x0040 /* Only available to admins */
 #define   QCMD_DEV            0x0080 /* Only available to developers */
+#define   QCMD_STAFF          0x0200 /* Only available to staff */
 
 #define   QCMD_ALIAS          0x0100 /* Don't list on SHOWCOMMANDS */
+#define   QCMD_HIDDEN         QCMD_ALIAS
 
 #define   CS_INIT_DB          0x1    /* Loading database.. */
 #define   CS_INIT_NOUSER      0x2    /* Loaded DB, waiting for user to be created */
@@ -533,6 +554,8 @@ typedef struct reguser {
   int                 stealcount;    /* How many times we've had to free the nick up */
   nick               *fakeuser;      /* If we had to "take" the nick, here's the pointer */
 
+  time_t             lastpasschange;
+
   struct reguser     *nextbydomain;
   struct reguser     *nextbyname;
   struct reguser     *nextbyID;
@@ -644,7 +667,10 @@ extern unsigned int lastmaillockID;
 
 extern int chanserv_init_status;
 extern int chanservdb_ready;
-extern PQModuleIdentifier q9pqid, q9apqid, q9cpqid, q9upqid;
+
+#ifndef CS_NODB
+extern DBModuleIdentifier q9dbid, q9adbid, q9cdbid, q9udbid;
+#endif
 
 extern maildomain *maildomainnametable[MAILDOMAINHASHSIZE];
 extern maildomain *maildomainIDtable[MAILDOMAINHASHSIZE];
@@ -673,6 +699,8 @@ extern sstring **chantypes;
 
 extern maillock *maillocks;
 
+extern sstring *cs_quitreason;
+
 /* Function prototypes */
 
 /* chanserv.c */
@@ -747,10 +775,10 @@ char *csdb_gethelpstr(char *command, int language);
 void csdb_createmail(reguser *rup, int type);
 void csdb_dohelp(nick *np, Command *cmd);
 
-#define q9asyncquery(handler, tag, format, ...) pqasyncqueryi(q9pqid, handler, tag, format , ##__VA_ARGS__)
-#define q9a_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9apqid, handler, tag, format , ##__VA_ARGS__)
-#define q9u_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9upqid, handler, tag, format , ##__VA_ARGS__)
-#define q9c_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9cpqid, handler, tag, format , ##__VA_ARGS__)
+#define q9asyncquery(handler, tag, format, ...) dbasyncqueryi(q9dbid, handler, tag, format , ##__VA_ARGS__)
+#define q9a_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9adbid, handler, tag, format , ##__VA_ARGS__)
+#define q9u_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9udbid, handler, tag, format , ##__VA_ARGS__)
+#define q9c_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cdbid, handler, tag, format , ##__VA_ARGS__)
 
 /* chanservcrypto.c */
 typedef int (*CRAlgorithm)(char *, const char *, const char *, const char *);
@@ -762,14 +790,15 @@ CRAlgorithm cs_cralgorithm(const char *algorithm);
 const char *cs_cralgorithmlist(void);
 int cs_checkhashpass(const char *username, const char *password, const char *junk, const char *hash);
 char *csc_generateresetcode(time_t lockuntil, char *username);
+int csc_verifyqticket(char *data, char *digest);
 
 /* chanservuser.c */
 void chanservreguser(void *arg);
 void chanservjoinchan(channel *cp);
 #define chanservsendmessage(np, fmt, args...) chanservsendmessage_real(np, 0, fmt , ## args)
 #define chanservsendmessageoneline(np, fmt, args...) chanservsendmessage_real(np, 1, fmt , ## args)
-void chanservsendmessage_real(nick *np, int oneline, char *message, ... );
-void chanservwallmessage(char *message, ... );
+void chanservsendmessage_real(nick *np, int oneline, char *message, ... ) __attribute__ ((format (printf, 3, 4)));;
+void chanservwallmessage(char *message, ... ) __attribute__ ((format (printf, 1, 2)));
 void chanservcommandinit();
 void chanservcommandclose();
 void chanservstdmessage(nick *np, int messageid, ... );
@@ -803,11 +832,13 @@ flag_t cs_sanitisechanlev(flag_t flags);
 typedef int (*UnbanFN)(void *arg, struct chanban *ban);
 int cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans, int abortonfailure);
 void cs_logchanop(regchan *rcp, char *nick, reguser *rup);
+int checkreason(nick *np, char *reason);
 
 /* chanservstdcmds.c */
 int cs_doshowcommands(void *source, int cargc, char **cargv);
 int cs_dohelp(void *source, int cargc, char **cargv);
 int cs_doquit(void *source, int cargc, char **cargv);
+int cs_dosetquitreason(void *source, int cargc, char **cargv);
 int cs_dorename(void *source, int cargc, char **cargv);
 int cs_dorehash(void *source, int cargc, char **cargv);
 int cs_doversion(void *source, int cargc, char **cargv);
@@ -840,7 +871,7 @@ chanindex *cs_checkaccess(nick *np, const char *chan, unsigned int flags, chanin
 /* chanservlog.c */
 void cs_initlog();
 void cs_closelog();
-void cs_log(nick *np, char *event, ...);
+void cs_log(nick *np, char *event, ...) __attribute__ ((format (printf, 2, 3)));
 
 /* chanservdump.c */
 int dumplastjoindata(const char *filename);
@@ -876,7 +907,7 @@ void csdb_deletemaildomain(maildomain *mdp);
 void csdb_createmaildomain(maildomain *mdp);
 void csdb_updatemaildomain(maildomain *mdp);
 void csdb_chanlevhistory_insert(regchan *rcp, nick *np, reguser *trup, flag_t oldflags, flag_t newflags);
-void csdb_accounthistory_insert(nick *np, char *oldpass, char *newpass, sstring *oldemail, sstring *newemail);
+void csdb_accounthistory_insert(nick *np, char *oldpass, char *newpass, char *oldemail, char *newemail);
 void csdb_cleanuphistories();
 void csdb_deletemaillock(maillock *mlp);
 void csdb_createmaillock(maillock *mlp);
@@ -885,4 +916,10 @@ void csdb_updatemaillock(maillock *mlp);
 /* q9snprintf.c */
 void q9snprintf(char *buf, size_t size, const char *format, const char *args, ...);
 void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, va_list ap);
+void q9strftime(char *buf, size_t size, time_t t);
+
+/* chanserv_flags.c */
+u_int64_t cs_accountflagmap(reguser *rup);
+u_int64_t cs_accountflagmap_str(char *flags);
+
 #endif