]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Redo standard message API, can't do much cool stuff yet but it's a start.
authorChris Porter <redacted>
Fri, 14 Mar 2008 02:54:05 +0000 (02:54 +0000)
committerChris Porter <redacted>
Fri, 14 Mar 2008 02:54:05 +0000 (02:54 +0000)
.hgignore
chanserv/Makefile
chanserv/chanserv.h
chanserv/chanserv_messages.h [new file with mode: 0644]
chanserv/chanservuser.c
chanserv/database/Makefile
chanserv/database/chanservdb_messages.c
chanserv/q9snprintf.c [new file with mode: 0644]
chanserv/usercmds/maillock.c

index fb6e43e05e92690bb8c0c5853f7906dad7a4fa93..8f6f1dd860fd5c08c3b524b50d209cc63bc25469 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -16,3 +16,4 @@ ktrace.out
 newserv.core
 *.log
 *.dump
+chanservlog
index a1bf5e692699957b3da2cb3c80f1f4546e962bc1..df17118002aed0906b4c3f2b819df54244e81b02 100644 (file)
@@ -12,7 +12,7 @@ clean:
        rm -f */*.o */*.so
 
 chanserv.so: chanservdb_updates.o chanserv.o chanservuser.o chanservnetevents.o chanservprivs.o chanservlog.o chanservstdcmds.o \
-               chanservdump.o chanservschedule.o chanservcrypto.o authlib.o
+               chanservdump.o chanservschedule.o chanservcrypto.o authlib.o q9snprintf.o
        ld -shared -Bdynamic ${LIBPGSQL} -o $@ $^
 
 chanserv_protect.so: chanserv_protect.o
index 97940cdf4eb55e761ec9bc05a98ea8c9d27024a1..5673151c99392cd64ced1ec239986aeb0836d905 100644 (file)
@@ -10,6 +10,7 @@
 #define _GNU_SOURCE
 #include <string.h>
 #include <time.h>
+#include <stdarg.h>
 #include "../lib/sstring.h"
 #include "../core/schedule.h"
 #include "../lib/flags.h"
@@ -72,7 +73,6 @@
 
 /* Number of languages and messages */
 #define MAXLANG      50
-#define MAXMESSAGES  200
 
 /* Maximum number of user chanlevs and bans */
 #define MAXCHANLEVS  250
 #define ENTROPYSOURCE "/dev/urandom"
 #define ENTROPYLEN    8
 
-/* The list of messages */
-#define QM_PROTECTED                 0
-#define QM_UNKNOWNCMD                1
-#define QM_SECUREONLY                2
-#define QM_AUTHEDONLY                3
-#define QM_UNAUTHEDONLY              4
-#define QM_COMMANDLIST               5
-#define QM_ENDOFLIST                 6
-#define QM_DONE                      7
-#define QM_NOTENOUGHPARAMS           8
-#define QM_UNKNOWNCHAN               9
-#define QM_NOACCESSONCHAN           10
-#define QM_CURCHANFLAGS             11
-#define QM_CURFORCEMODES            12
-#define QM_NOACCESS                 13
-#define QM_UNKNOWNUSER              14
-#define QM_USERNOTAUTHED            15
-#define QM_CHANLEVHEADER            16
-#define QM_CHANLEVCOLSHORT          17
-#define QM_CHANLEVCOLFULL           18
-#define QM_NOUSERSONCHANLEV         19
-#define QM_CHANUSERFLAGS            20
-#define QM_CHANUSERUNKNOWN          21
-#define QM_INVALIDCHANLEVCHANGE     22
-#define QM_USERISAUTHEDAS           23
-#define QM_USERISHELPER             24
-#define QM_USERISOPER               25
-#define QM_USERISADMIN              26
-#define QM_USERISDEV                27
-#define QM_WHOISHEADER              28
-#define QM_WHOISCOLS                29
-#define QM_USERONNOCHANS            30
-#define QM_CHANAUTOLIMIT            31
-#define QM_CHANBANAUTOREMOVE        32
-#define QM_NOCHANBANAUTOREMOVE      33
-#define QM_INVALIDCHANNAME          34
-#define QM_ALREADYREGISTERED        35
-#define QM_CURUSERFLAGS             36
-#define QM_WELCOMEMESSAGEIS         37
-#define QM_GLOBALINFO               38
-#define QM_CHANNELINFO              39
-#define QM_PROTECTEDNICK            40
-#define QM_NICKWASFAKED             41
-#define QM_NOTPROTECTED             42
-#define QM_SAMEAUTH                 43
-#define QM_AUTHFAIL                 44
-#define QM_AUTHOK                   45
-#define QM_NEWACCOUNT               46
-#define QM_AUTHNAMEINUSE            47
-#define QM_ALREADYONCHAN            48
-#define QM_NOTONCHAN                49
-#define QM_ALREADYOPPED             50
-#define QM_USERNOTONCHAN            51
-#define QM_USEROPPEDONCHAN          52
-#define QM_CANTOP                   53
-#define QM_NOTOPPED                 54
-#define QM_ALREADYVOICED            55
-#define QM_NOTVOICED                56
-#define QM_USERVOICEDONCHAN         57
-#define QM_REGBANHEADER             58
-#define QM_NOBANS                   59
-#define QM_REMOVEDCHANBAN           60
-#define QM_NOTREMOVEDPERMBAN        61
-#define QM_REMOVEDPERMBAN           62
-#define QM_CANTVOICE                63
-#define QM_NOHELP                   64
-#define QM_WHOISHEADER_NICK         65
-#define QM_WHOISHEADER_AUTH         66
-#define QM_WHOIS_USERS              67
-#define QM_WHOIS_LASTAUTH           68
-#define QM_WHOIS_LASTUSERHOST       69
-#define QM_WHOIS_USERID             70
-#define QM_WHOIS_INFO               71
-#define QM_WHOIS_COMMENT            72
-#define QM_WHOIS_FLAGS              73
-#define QM_WHOIS_CREATED            74
-#define QM_WHOIS_CHANHEADER         75
-#define QM_WHOIS_EMAIL              76
-#define QM_WHOIS_EMAILSET           77
-#define QM_COMMENT                  78
-#define QM_NOCOMMENT                79
-#define QM_BADAUTH                  80
-#define QM_USERHASBADAUTH           81
-#define QM_BADEMAIL                 82
-#define QM_MAILTHROTTLED            83
-#define QM_MAILQUEUED               84
-#define QM_PWDONTMATCH              85
-#define QM_PWTOSHORT                86
-#define QM_PWCHANGED                87
-#define QM_INVALIDDURATION2         88
-#define QM_EMAILCHANGED             89
-#define QM_EMAILDONTMATCH           90
-#define QM_INVALIDEMAIL             91
-#define QM_EMAILTOOSHORT            92
-#define QM_NOTYOUREMAIL             93
-#define QM_EMAILNOAT                94
-#define QM_EMAILATEND               95
-#define QM_EMAILINVCHR              96
-#define QM_CHANNELNOTSUSPENDED      97
-#define QM_CHANNELALREADYSUSPENDED  98
-#define QM_CHANTYPE                 99
-#define QM_UNKNOWNCHANTYPE         100
-#define QM_FOUNDER                 101
-#define QM_ADDEDBY                 102
-#define QM_ALREADYKNOWNONCHAN      103
-#define QM_CANNOTREMOVEOWNER       104
-#define QM_CANNOTREMOVEMASTER      105
-#define QM_UNKNOWNBAN              106
-#define QM_YOURLANGUAGE            107
-#define QM_LANGUAGELIST            108
-#define QM_UNKNOWNLANGUAGE         109
-#define QM_WHOIS_USERLANG          110
-#define QM_CHANTYPEIS              111
-#define QM_STATSHEADER             112
-#define QM_STATSADDED              113
-#define QM_STATSJOINS              114
-#define QM_STATSLASTACTIVE         115
-#define QM_AUTHSUSPENDED           116
-#define QM_REASON                  117
-#define QM_EXPIRES                 118
-#define QM_TOOMANYAUTHS            119
-#define QM_INVALIDDURATION         120
-#define QM_DISCONNECTINGUSER       121
-#define QM_USERALREADYSUSPENDED    122
-#define QM_USERNOTSUSPENDED        123
-#define QM_SPEWHEADER              124
-#define QM_TOOMANYRESULTS          125
-#define QM_RESULTCOUNT             126
-#define QM_SUSPENDKILL             127
-#define QM_LISTFLAGSHEADER         128
-#define QM_SUSPENDUSERLISTHEADER   129
-#define QM_SUSPENDCHANLISTHEADER   130
-#define QM_NOREQUESTOWNER          131
-#define QM_GRANTEDOWNER            132
-#define QM_AUTHHISTORYHEADER       133
-#define QM_CURDOMAINMODES          134
-#define QM_SPEWDOMAINHEADER        135
-#define QM_DOMAINLIMIT             136
-#define QM_PWTOWEAK                137
-#define QM_GIVEOWNERNOTMASTER      138
-#define QM_GIVEOWNERALREADYOWNER   139
-#define QM_GIVEOWNERNEEDHASH       140
-#define QM_GIVEOWNERWRONGHASH      141
-#define QM_SHOWINGDURATION         142
-#define QM_INVALIDACCOUNTNAME      143
-#define QM_CHALLENGEBADALGORITHM   144
-#define QM_NOCHALLENGE             145
-#define QM_USEGIVEOWNER            146
-#define QM_NOFLAGSPECIFIED         147
-#define QM_NEWBANALREADYBANNED     148
-#define QM_NEWBANOVERLAPS          149
-#define QM_REPLACINGTEMPBAN        150
-#define QM_PERMBANALREADYSET       151
-#define QM_NOTREPLACINGBANLDURATION 152
-#define QM_REPLACINGBANSDURATION   153
-#define QM_TOOMANYCHANLEVS         154
-#define QM_TOOMANYBANS             155
-#define QM_WARNNOTREMOVEDPERMBAN   156
-#define QM_MAXHELLOLIMIT           157
-#define QM_ADDRESSLIMIT            158
-#define QM_DOMAINBANNED            159
-#define QM_TYPEHELPFORHELP         160
-#define QM_REQUESTPASSPRIVUSER     161
-#define QM_EMAILMATCHESOLD         162
-#define QM_INVALIDLIMIT            163
-#define QM_ACCOUNTLOCKED           164
-#define QM_ACCOUNTNOTLOCKED        165
-#define QM_RESETOK                 166
-#define QM_BADRESETCODE            167
-#define QM_CHALLENGEDDEPRECATED    168
-#define QM_CHANLEVSUMMARY          169
-#define QM_MAILLOCKHEADER          170
-#define QM_MAILLOCKLINE            171
-#define QM_MAILLOCKDOESNTEXIST     172
-#define QM_MAILLOCKALREADYEXISTS   173
-#define QM_MAILLOCKED              174
-#define QM_NOACCESSONUSER          175
-#define QM_NOCHANOPHISTORY         176
-#define QM_CHANOPHISTORYHEADER     177
-#define QM_OTHERUSERAUTHEDLIMIT    178
-#define QM_OTHERUSERAUTHED         179
-#define QM_STATSRESET              180
-#define QM_CHANLEVEMPTIEDCHANNEL   181
-#define QM_CHANLEVCHANGED          182
-#define QM_CHANLEVREMOVED          183
-#define QM_CHANLEVNOCHANGE         184
-#define QM_USERSHEADER             185
-#define QM_EMPTYCHAN               186
-#define QM_USERSSUMMARY            187
+#include "chanserv_messages.h"
 
 /* List of privileged operations */
 
@@ -849,7 +661,6 @@ extern cslang *cslanguages[MAXLANG];
 extern unsigned int cslangcount;
 
 extern sstring *csmessages[MAXLANG][MAXMESSAGES];
-extern char *defaultmessages[MAXMESSAGES];
 
 extern const flag rcflags[];
 extern const flag rcuflags[];
@@ -1071,4 +882,7 @@ void csdb_deletemaillock(maillock *mlp);
 void csdb_createmaillock(maillock *mlp);
 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);
 #endif
diff --git a/chanserv/chanserv_messages.h b/chanserv/chanserv_messages.h
new file mode 100644 (file)
index 0000000..d25fa37
--- /dev/null
@@ -0,0 +1,206 @@
+#ifndef __CHANSERV_MESSAGES_H
+#define __CHANSERV_MESSAGES_H
+
+#define MAXMESSAGES  200
+
+#ifdef COMPILING_MESSAGES
+#define msg(token, message, args) message, args
+#define BeginMessages() char *defaultmessages[MAXMESSAGES*2] =
+#define EndMessages();
+#else
+#define msg(token, message, argsx) token
+#define BeginMessages(x) typedef enum csrawmessages
+#define EndMessages() csrawmessages; extern char *defaultmessages[MAXMESSAGES*2];
+#endif
+
+BeginMessages() {
+  msg(QM_PROTECTED, "Channel $0 is protected by $1.", "ss"),
+  msg(QM_UNKNOWNCMD, "Unknown command $0.  Type SHOWCOMMANDS for a list of available commands.", "s"),
+  msg(QM_SECUREONLY, "To prevent sensitive information being accidentally send to malicious users\non other networks, when using the $0 command, you must use\n/msg $1@$2.", "sss"),
+  msg(QM_AUTHEDONLY, "$0 is only available to authed users.  Try AUTH to authenticate with your\naccount, or HELLO to create an account.", "s"),
+  msg(QM_UNAUTHEDONLY, "$0 is not available once you have authed.", "s"),
+  msg(QM_COMMANDLIST, "The following commands are available to you.\nFor more information on a specific command, type HELP <command>:", ""),
+  msg(QM_ENDOFLIST, "End of list.", ""),
+  msg(QM_DONE, "Done.", ""),
+  msg(QM_NOTENOUGHPARAMS, "You didn't provide enough parameters for $0.", "s"),
+  msg(QM_UNKNOWNCHAN, "Channel $0 is unknown or suspended.", "s"),
+  msg(QM_NOACCESSONCHAN, "You do not have sufficient access on $0 to use $1.", "ss"),
+  msg(QM_CURCHANFLAGS, "Current channel flags for $0: $1", "ss"),
+  msg(QM_CURFORCEMODES, "Current forced modes on $0: $1", "ss"),
+  msg(QM_NOACCESS, "You do not have sufficient privileges to use $0.", "s"),
+  msg(QM_UNKNOWNUSER, "Can't find user $0.", "s"),
+  msg(QM_USERNOTAUTHED, "User $0 is not authed.", "s"),
+  msg(QM_CHANLEVHEADER, "Known users on $0:", "s"),
+  msg(QM_CHANLEVCOLSHORT, "Username        Flags", ""),
+  msg(QM_CHANLEVCOLFULL, "Username        Flags         Last join       Last changed    ", ""),
+  msg(QM_NOUSERSONCHANLEV, "No known users found on $0.", "s"),
+  msg(QM_CHANUSERFLAGS, "Flags for $0 on $1: $2", "sss"),
+  msg(QM_CHANUSERUNKNOWN, "User $0 is not known on $1.", "ss"),
+  msg(QM_INVALIDCHANLEVCHANGE, "Invalid or disallowed flag specified.", ""),
+  msg(QM_USERISAUTHEDAS, "$0 is authed as $1.", "ss"),
+  msg(QM_USERISHELPER, "Network Staff  : Helper", ""),
+  msg(QM_USERISOPER, "Network Staff  : IRC Operator", ""),
+  msg(QM_USERISADMIN, "Network Staff  : IRC Administrator", ""),
+  msg(QM_USERISDEV, "Network Staff  : Developer", ""),
+  msg(QM_WHOISHEADER, "$0 is known on the following channels:", "s"),
+  msg(QM_WHOISCOLS, "Channel                        Flags", ""),
+  msg(QM_USERONNOCHANS, "$0 is not known on any channels.", "s"),
+  msg(QM_CHANAUTOLIMIT, "Current autolimit setting on $0: $1", "sd"),
+  msg(QM_CHANBANAUTOREMOVE, "Bans on $0 will be removed after: $1", "ss"),
+  msg(QM_NOCHANBANAUTOREMOVE, "Bans on $0 will not be automatically removed.", "s"),
+  msg(QM_INVALIDCHANNAME, "$0 is not a valid channel name.", "s"),
+  msg(QM_ALREADYREGISTERED, "$0 is already registered.", "s"),
+  msg(QM_CURUSERFLAGS, "User flags for $0: $1", "ss"),
+  msg(QM_WELCOMEMESSAGEIS, "Welcome message for $0: $1", "ss"),
+  msg(QM_GLOBALINFO, "Default info line: $0", "s"),
+  msg(QM_CHANNELINFO, "Info line on $0: $1", "ss"),
+  msg(QM_PROTECTEDNICK, "$0 is a protected helper or oper nick.  Please use a different nickname.", "s"),
+  msg(QM_NICKWASFAKED, "I created a fakeuser $0 to prevent your nick being stolen.", "s"),
+  msg(QM_NOTPROTECTED, "Sorry, your nick $0 is not protected.", "s"),
+  msg(QM_SAMEAUTH, "$0 is authed as $1.  Cannot reclaim nick.", "ss"),
+  msg(QM_AUTHFAIL, "Username or password incorrect.", ""),
+  msg(QM_AUTHOK, "You are now logged in as $0.", "s"),
+  msg(QM_NEWACCOUNT, "User $0 created successfully.\nInformation about how to access and use your new account will be sent to your email address, $1.\nIf you do not see an email soon be sure to check your spam folder.", "ss"),
+  msg(QM_AUTHNAMEINUSE, "A user with that name already exists.  If you have said HELLO before, use AUTH to\nlogin, or REQUESTPASSWORD if you have forgotten the password.  Otherwise,\nplease change your nick and try again.", ""),
+  msg(QM_ALREADYONCHAN, "You're already on $0.", "s"),
+  msg(QM_NOTONCHAN, "You're not on $0.", "s"),
+  msg(QM_ALREADYOPPED, "You're already opped on $0.", "s"),
+  msg(QM_USERNOTONCHAN, "$0 is not on $1.", "ss"),
+  msg(QM_USEROPPEDONCHAN, "$0 is already opped on $1.", "ss"),
+  msg(QM_CANTOP, "Channel settings prevent $0 being opped on $1.", "ss"),
+  msg(QM_NOTOPPED, "You're not opped on $0.", "s"),
+  msg(QM_ALREADYVOICED, "You're already voiced on $0.", "s"),
+  msg(QM_NOTVOICED, "You're not voiced on $0.", "s"),
+  msg(QM_USERVOICEDONCHAN, "$0 is already voiced on $1.", "ss"),
+  msg(QM_REGBANHEADER, "Registered bans on $0:\nID  Hostmask                      Expires            Set by           Reason", "s"),
+  msg(QM_NOBANS, "No bans on $0.", "s"),
+  msg(QM_REMOVEDCHANBAN, "Removed channel ban $0 from $1.", "ss"),
+  msg(QM_NOTREMOVEDPERMBAN, "You need the master flag to remove registered ban $0 from $1.", "ss"),
+  msg(QM_REMOVEDPERMBAN, "Removed registered ban $0 from $1.", "ss"),
+  msg(QM_CANTVOICE, "Channel settings prevent $0 being voiced on $1.", "ss"),
+  msg(QM_NOHELP, "Sorry, no help available for $0.", "s"),
+  msg(QM_WHOISHEADER_NICK, "-Information for user $0 (using account $1):", "ss"),
+  msg(QM_WHOISHEADER_AUTH, "-Information for account $0:", "s"),
+  msg(QM_WHOIS_USERS, "Account users  : $0", "s"),
+  msg(QM_WHOIS_LASTAUTH, "Last auth      : $0", "s"),
+  msg(QM_WHOIS_LASTUSERHOST, "Last user@host : $0", "s"),
+  msg(QM_WHOIS_USERID, "User ID        : $0", "d"),
+  msg(QM_WHOIS_INFO, "Info           : $0", "s"),
+  msg(QM_WHOIS_COMMENT, "Staff comment  : $0", "s"),
+  msg(QM_WHOIS_FLAGS, "User flags     : $0", "s"),
+  msg(QM_WHOIS_CREATED, "User created   : $0", "s"),
+  msg(QM_WHOIS_CHANHEADER, "Known on the following channels:\nChannel                        Flags", ""),
+  msg(QM_WHOIS_EMAIL, "Email address  : $0", "s"),
+  msg(QM_WHOIS_EMAILSET, "Email last set : $0", "s"),
+  msg(QM_COMMENT, "Staff comment for $0: $1.", "ss"),
+  msg(QM_NOCOMMENT, "No staff comment for $0.", "s"),
+  msg(QM_BADAUTH, "$0: Your account has been deleted or suspended.", "s"),
+  msg(QM_USERHASBADAUTH, "Account $0 has been deleted.", "s"),
+  msg(QM_BADEMAIL, "Sorry, no accounts have that email address.", ""),
+  msg(QM_MAILTHROTTLED, "Sorry, but you have already requested a password. You will have to wait atleast $0 hours, before requesting again.", "g"),
+  msg(QM_MAILQUEUED, "Mail queued for delivery", ""),
+  msg(QM_PWDONTMATCH, "Sorry, but passwords do not match", ""),
+  msg(QM_PWTOSHORT, "Sorry, but new password is to short", ""),
+  msg(QM_PWCHANGED, "Ok, password changed", ""),
+  msg(QM_INVALIDDURATION2, "Duration too long or invalid: $0", "s"),
+  msg(QM_EMAILCHANGED, "Ok, email changed to \"$0\"", "s"),
+  msg(QM_EMAILDONTMATCH, "Sorry, but first and second email addresses don't match", ""),
+  msg(QM_INVALIDEMAIL, "$0 is not a valid email address", "s"),
+  msg(QM_EMAILTOOSHORT, "Email ($0) too short", "s"),
+  msg(QM_NOTYOUREMAIL, "\"$0\" is not your email address", "s"),
+  msg(QM_EMAILNOAT, "Email ($0) must contain at least one at sign (@)", "s"),
+  msg(QM_EMAILATEND, "Email ($0) can't end with an at sign (@)", "s"),
+  msg(QM_EMAILINVCHR, "Email ($0) contains invalid characters", "s"),
+  msg(QM_CHANNELNOTSUSPENDED, "Channel $0 is not suspended.", "s"),
+  msg(QM_CHANNELALREADYSUSPENDED, "Channel $0 is already suspended.", "s"),
+  msg(QM_CHANTYPE, "Channel type: $0", "s"),
+  msg(QM_UNKNOWNCHANTYPE, "$0: unknown channel type", "s"),
+  msg(QM_FOUNDER, "Original founder: $0", "s"),
+  msg(QM_ADDEDBY, "Added by: $0", "s"),
+  msg(QM_ALREADYKNOWNONCHAN, "$0 is already known on $1.", "ss"),
+  msg(QM_CANNOTREMOVEOWNER, "Not removing channel owner $0 from $1.", "ss"),
+  msg(QM_CANNOTREMOVEMASTER, "Not removing channel master $0 from $1.", "ss"),
+  msg(QM_UNKNOWNBAN, "Can't find ban $0 on $1.", "ss"),
+  msg(QM_YOURLANGUAGE, "Your language is currently set to: $0.", "s"),
+  msg(QM_LANGUAGELIST, "The following languages are currently known:", ""),
+  msg(QM_UNKNOWNLANGUAGE, "Unknown language code: $0.", "s"),
+  msg(QM_WHOIS_USERLANG, "Language       : $0", "s"),
+  msg(QM_CHANTYPEIS, "Channel type for $0 is: $1", "ss"),
+  msg(QM_STATSHEADER, "Statistics for $0:", "s"),
+  msg(QM_STATSADDED, "Date added: $0", "s"),
+  msg(QM_STATSJOINS, "Since $0: maximum size $1, $2 joins ($3 joins/day).", "sddg"),
+  msg(QM_STATSLASTACTIVE, "Last active: $0", "s"),
+  msg(QM_AUTHSUSPENDED, "Your Q account is suspended.", ""),
+  msg(QM_REASON, "Reason: $0", "s"),
+  msg(QM_EXPIRES, "Expires: $0", "s"),
+  msg(QM_TOOMANYAUTHS, "Too many users AUTH'd to this account.", ""),
+  msg(QM_INVALIDDURATION, "Duration must be between 1d and 1M.", ""),
+  msg(QM_DISCONNECTINGUSER, "Disconnecting $0 (authed as $1)", "ss"),
+  msg(QM_USERALREADYSUSPENDED, "User is already suspended.", ""),
+  msg(QM_USERNOTSUSPENDED, "User $0 is not suspended.", "s"),
+  msg(QM_SPEWHEADER, "Username:       Suspended: Email:                         Last user@host:", ""),
+  msg(QM_TOOMANYRESULTS, "Found over $0 $1, truncating list.", "ds"),
+  msg(QM_RESULTCOUNT, "Found $0 $1$2.", "uss"),
+  msg(QM_SUSPENDKILL, "Attention: Your Q account has been suspended. You are being disconnected.", ""),
+  msg(QM_LISTFLAGSHEADER, "Username:       Flags:            Suspended: Email:                         Last user@host:", ""),
+  msg(QM_SUSPENDUSERLISTHEADER, "Username:       Suspend type: Suspended by:   Date suspended: Expires:        Reason:", ""),
+  msg(QM_SUSPENDCHANLISTHEADER, "Channel:                       Suspended by:   Date suspended: Reason:", ""),
+  msg(QM_NOREQUESTOWNER, "You cannot request ownership of $0 as there is a channel $1 present.", "ss"),
+  msg(QM_GRANTEDOWNER, "You have been granted ownership of $0.", "s"),
+  msg(QM_AUTHHISTORYHEADER, "#:  User:                                              Authed:         Disconnected:   Reason:", ""),
+  msg(QM_CURDOMAINMODES, "Current modes on $0: $1", "ss"),
+  msg(QM_SPEWDOMAINHEADER, "Domain:             Users:  Flags:", ""),
+  msg(QM_DOMAINLIMIT, "Sorry, no more accounts are allowed from this email domain.", ""),
+  msg(QM_PWTOWEAK, "Password too weak - You need to avoid repeating characters, and have different character types (e.g. 1 number and 1 letter)", ""),
+  msg(QM_GIVEOWNERNOTMASTER, "User $0 is not a master on $1 - you must promote user to master status first.", "ss"),
+  msg(QM_GIVEOWNERALREADYOWNER, "User $0 is already an owner on $1.", "ss"),
+  msg(QM_GIVEOWNERNEEDHASH, "WARNING: This command will give COMPLETE control over $0 to $1,\nincluding the ability to remove you as owner.  If you are sure you want to\ndo this, type: GIVEOWNER $2 #$3 $4", "sssss"),
+  msg(QM_GIVEOWNERWRONGHASH, "Hash value incorrect, try again.", ""),
+  msg(QM_SHOWINGDURATION, "Showing $0 for last $1.", "ss"),
+  msg(QM_INVALIDACCOUNTNAME, "Change your nickname to something with none of the following characters: `~^[]{}|_\\", ""),
+  msg(QM_CHALLENGEBADALGORITHM, "Invalid digest algorithm.", ""),
+  msg(QM_NOCHALLENGE, "Challenge has either not been requested or has expired.", ""),
+  msg(QM_USEGIVEOWNER, "For security reasons it is not possible to give the owner flag to other users\nusing CHANLEV.  Use GIVEOWNER if you really wanted to do this.", ""),
+  msg(QM_NOFLAGSPECIFIED, "You must specify at least one valid flag to add.", ""),
+  msg(QM_NEWBANALREADYBANNED, "New ban is already contained within existing ban: $0", "s"),
+  msg(QM_NEWBANOVERLAPS, "New ban would replace at least one existing ban ($0), use UNBANMASK $1 first if you want to set this ban.", "ss"),
+  msg(QM_REPLACINGTEMPBAN, "A temporary ban with this mask already exists, replacing it.", ""),
+  msg(QM_PERMBANALREADYSET, "That permanent ban already exists.", ""),
+  msg(QM_NOTREPLACINGBANLDURATION, "That ban is already set with a longer duration.", ""),
+  msg(QM_REPLACINGBANSDURATION, "Replaced existing ban which was set with a shorter duration.", ""),
+  msg(QM_TOOMANYCHANLEVS, "Channel has too many user entries, aborting.", ""),
+  msg(QM_TOOMANYBANS, "No more bans are allowed on that channel.", ""),
+  msg(QM_WARNNOTREMOVEDPERMBAN, "Warning: not removing registered ban $0 from $1.", "ss"),
+  msg(QM_MAXHELLOLIMIT, "Sorry, the registration service is unavailable to you at this time. Please try again later.", ""),
+  msg(QM_ADDRESSLIMIT, "Too many accounts exist from this email address.", ""),
+  msg(QM_DOMAINBANNED, "That email address has been blocked.", ""),
+  msg(QM_TYPEHELPFORHELP, "For more information, type HELP $0.", "s"),
+  msg(QM_REQUESTPASSPRIVUSER, "Cannot send password for that account.", ""),
+  msg(QM_EMAILMATCHESOLD, "The new email address is the same as current one.", ""),
+  msg(QM_INVALIDLIMIT, "Supplied autolimit is invalid: $0", "s"),
+  msg(QM_ACCOUNTLOCKED, "This account has recently been modified. It will be unlocked on $0.", "s"),
+  msg(QM_ACCOUNTNOTLOCKED, "That account is not locked.", ""),
+  msg(QM_RESETOK, "Your old account settings have been restored, please check your email.", ""),
+  msg(QM_BADRESETCODE, "Bad reset code.", ""),
+  msg(QM_CHALLENGEDDEPRECATED, "WARNING: the selected algorithm is legacy functionality and is likely to be removed in the near future.", ""),
+  msg(QM_CHANLEVSUMMARY, "Total: $0 (owner: $1, master: $2, op: $3, voice: $4, known: $5, ban: $6).", "ddddddd"),
+  msg(QM_MAILLOCKHEADER, "Pattern:                                           Created by:     Reason:                   Created:", ""),
+  msg(QM_MAILLOCKDOESNTEXIST, "That pattern doesn't exist.", ""),
+  msg(QM_MAILLOCKALREADYEXISTS, "That pattern already exists!", ""),
+  msg(QM_MAILLOCKED, "Sorry, you can't use that email address.", ""),
+  msg(QM_NOACCESSONUSER, "You do not have sufficient access to use $0 on $1.", "ss"),
+  msg(QM_NOCHANOPHISTORY, "No channel op events have been logged for $0.", "s"),
+  msg(QM_CHANOPHISTORYHEADER, "Channel op events on $0:\nNickname        Account used", "s"),
+  msg(QM_OTHERUSERAUTHEDLIMIT, "Warning: $0 ($1@$2) attempted to auth with your password but you already had $3 users authed to your account.", "sssd"),
+  msg(QM_OTHERUSERAUTHED, "Warning: $0 ($1@$2) authed with your password.", "sss"),
+  msg(QM_STATSRESET, "Resettable statistics reset for $0.", "s"),
+  msg(QM_CHANLEVEMPTIEDCHANNEL, "The channel has been deleted since the last known user was removed.", ""),
+  msg(QM_CHANLEVCHANGED, "Done.  Flags for $0 on $1 are now: $2.", "sss"),
+  msg(QM_CHANLEVREMOVED, "Done.  User $0 is no longer known on $1.", "ss"),
+  msg(QM_CHANLEVNOCHANGE, "No change - check that you didn't specify an impossible flag combination.", ""),
+  msg(QM_USERSHEADER, "Users currently on $0:\nNick            Username        Flags        Host", "s"),
+  msg(QM_EMPTYCHAN, "Channel $0 is currently empty.", "s"),
+  msg(QM_USERSSUMMARY, "Total $0 users: $1 opped, $2 voiced, $3 others, $4 with flags ($5 ops, $6 masters)", "ddddddd"),
+} 
+EndMessages()
+#endif
index d7baeb4abfc2244cb8f2b51640745a8220706a22..f5e5db70174ee0a038935851f84b8a4c988d52aa 100644 (file)
@@ -327,7 +327,7 @@ void chanservstdmessage(nick *np, int messageid, ... ) {
   reguser *rup;
   int language;
   va_list va, va2;
-  char *message;
+  char *message, *messageargs;
   char *bp2,*bp;
   int len;
 
@@ -349,12 +349,14 @@ void chanservstdmessage(nick *np, int messageid, ... ) {
   } else if (csmessages[0][messageid]) {
     message=csmessages[0][messageid]->content;
   } else {
-    message=defaultmessages[messageid];
+    message=defaultmessages[messageid*2];
   }
 
+  messageargs=defaultmessages[messageid*2+1];
+
   va_start(va,messageid);
   va_copy(va2, va);
-  vsnprintf(buf,5000,message,va);
+  q9vsnprintf(buf,5000,message,messageargs,va);
   va_end(va);
 
   len=0;
@@ -474,7 +476,7 @@ void chanservwallmessage(char *message, ... ) {
 void chanservkillstdmessage(nick *target, int messageid, ... ) {
   char buf[512];
   int language;
-  char* message;
+  char *message, *messageargs;
   va_list va;
   reguser *rup;
   
@@ -488,10 +490,11 @@ void chanservkillstdmessage(nick *target, int messageid, ... ) {
   else if (csmessages[0][messageid])
     message=csmessages[0][messageid]->content;
   else
-    message=defaultmessages[messageid];
+    message=defaultmessages[messageid*2];
 
+  messageargs=defaultmessages[messageid*2+1];
   va_start(va, messageid);
-  vsnprintf(buf, 511, message, va);
+  q9vsnprintf(buf, 511, message, messageargs, va);
   va_end(va);
   killuser(chanservnick, target, buf);
 }
index e6ddc410e0691887a8a256ff16f17ee3b83b0684..816ebf72d96085e61b935401027ab5af377b5700 100644 (file)
@@ -5,3 +5,4 @@ all: chanservdb.so
 chanservdb.so: chanservdb.o chanservdb_alloc.o chanservdb_hash.o chanservdb_messages.o
        ld -shared -Bdynamic ${LIBPGSQL} -o $@ $^
         
+chanservdb_messages.o: chanservdb_messages.c ../chanserv_messages.h
index 219c65dabbc722b06d299cd6ebb59793e5fff315..8448a4d46b0cc1d4e8633daf7ea45c73e0bde761 100644 (file)
@@ -1,3 +1,6 @@
+#define COMPILING_MESSAGES
+#include "../chanserv_messages.h"
+
 #include "../chanserv.h"
 
 cslang *cslanguages[MAXLANG];
@@ -5,197 +8,6 @@ unsigned int cslangcount;
 
 sstring *csmessages[MAXLANG][MAXMESSAGES];
 
-char *defaultmessages[MAXMESSAGES] = {
-  /*  0 */ "Channel %s is protected by %s.",
-  /*  1 */ "Unknown command %s.  Type SHOWCOMMANDS for a list of available commands.",
-  /*  2 */ "To prevent sensitive information being accidentally send to malicious users\non other networks, when using the %s command, you must use\n/msg %s@%s.",
-  /*  3 */ "%s is only available to authed users.  Try AUTH to authenticate with your\naccount, or HELLO to create an account.",
-  /*  4 */ "%s is not available once you have authed.",
-  /*  5 */ "The following commands are available to you.\nFor more information on a specific command, type HELP <command>:",
-  /*  6 */ "End of list.",
-  /*  7 */ "Done.",
-  /*  8 */ "You didn't provide enough parameters for %s.",
-  /*  9 */ "Channel %s is unknown or suspended.",
-  /* 10 */ "You do not have sufficient access on %s to use %s.",
-  /* 11 */ "Current channel flags for %s: %s",
-  /* 12 */ "Current forced modes on %s: %s",
-  /* 13 */ "You do not have sufficient privileges to use %s.",
-  /* 14 */ "Can't find user %s.",
-  /* 15 */ "User %s is not authed.",
-  /* 16 */ "Known users on %s:",
-  /* 17 */ "Username        Flags",
-  /* 18 */ "Username        Flags         Last join       Last changed    ",
-  /* 19 */ "No known users found on %s.",
-  /* 20 */ "Flags for %s on %s: %s",
-  /* 21 */ "User %s is not known on %s.",
-  /* 22 */ "Invalid or disallowed flag specified.",
-  /* 23 */ "%s is authed as %s.",
-  /* 24 */ "Network Staff  : Helper",
-  /* 25 */ "Network Staff  : IRC Operator",
-  /* 26 */ "Network Staff  : IRC Administrator",
-  /* 27 */ "Network Staff  : Developer",
-  /* 28 */ "%s is known on the following channels:",
-  /* 29 */ "Channel                        Flags",
-  /* 30 */ "%s is not known on any channels.",
-  /* 31 */ "Current autolimit setting on %s: %d",
-  /* 32 */ "Bans on %s will be removed after: %s",
-  /* 33 */ "Bans on %s will not be automatically removed.",
-  /* 34 */ "%s is not a valid channel name.",
-  /* 35 */ "%s is already registered.",
-  /* 36 */ "User flags for %s: %s",
-  /* 37 */ "Welcome message for %s: %s",
-  /* 38 */ "Default info line: %s",
-  /* 39 */ "Info line on %s: %s",
-  /* 40 */ "%s is a protected helper or oper nick.  Please use a different nickname.",
-  /* 41 */ "I created a fakeuser %s to prevent your nick being stolen.",
-  /* 42 */ "Sorry, your nick %s is not protected.",
-  /* 43 */ "%s is authed as %s.  Cannot reclaim nick.",
-  /* 44 */ "Username or password incorrect.",
-  /* 45 */ "You are now logged in as %s.",
-  /* 46 */ "User %s created successfully.\nInformation about how to access and use your new account will be sent to your email address, %s.\nIf you do not see an email soon be sure to check your spam folder.",
-  /* 47 */ "A user with that name already exists.  If you have said HELLO before, use AUTH to\nlogin, or REQUESTPASSWORD if you have forgotten the password.  Otherwise,\nplease change your nick and try again.",
-  /* 48 */ "You're already on %s.",
-  /* 49 */ "You're not on %s.",
-  /* 50 */ "You're already opped on %s.",
-  /* 51 */ "%s is not on %s.",
-  /* 52 */ "%s is already opped on %s.",
-  /* 53 */ "Channel settings prevent %s being opped on %s.",
-  /* 54 */ "You're not opped on %s.",
-  /* 55 */ "You're already voiced on %s.",
-  /* 56 */ "You're not voiced on %s.",
-  /* 57 */ "%s is already voiced on %s.",
-  /* 58 */ "Registered bans on %s:\nID  Hostmask                      Expires            Set by           Reason",
-  /* 59 */ "No bans on %s.",
-  /* 60 */ "Removed channel ban %s from %s.",
-  /* 61 */ "You need the master flag to remove registered ban %s from %s.",
-  /* 62 */ "Removed registered ban %s from %s.",
-  /* 63 */ "Channel settings prevent %s being voiced on %s.",
-  /* 64 */ "Sorry, no help available for %s.",  
-  /* 65 */ "-Information for user %s (using account %s):",
-  /* 66 */ "-Information for account %s:",
-  /* 67 */ "Account users  : %s",
-  /* 68 */ "Last auth      : %s",
-  /* 69 */ "Last user@host : %s",
-  /* 70 */ "User ID        : %d",
-  /* 71 */ "Info           : %s",
-  /* 72 */ "Staff comment  : %s",
-  /* 73 */ "User flags     : %s",
-  /* 74 */ "User created   : %s",
-  /* 75 */ "Known on the following channels:\nChannel                        Flags", 
-  /* 76 */ "Email address  : %s",
-  /* 77 */ "Email last set : %s",
-  /* 78 */ "Staff comment for %s: %s.",
-  /* 79 */ "No staff comment for %s.",
-  /* 80 */ "%s: Your account has been deleted or suspended.",
-  /* 81 */ "Account %s has been deleted.",
-  /* 82 */ "Sorry, no accounts have that email address.",
-  /* 83 */ "Sorry, but you have already requested a password. You will have to wait atleast %.1f hours, before requesting again.",
-  /* 84 */ "Mail queued for delivery",
-  /* 85 */ "Sorry, but passwords do not match",
-  /* 86 */ "Sorry, but new password is to short",
-  /* 87 */ "Ok, password changed",
-  /* 88 */ "Duration too long or invalid: %s",
-  /* 89 */ "Ok, email changed to \"%s\"",
-  /* 90 */ "Sorry, but first and second email addresses don't match",
-  /* 91 */ "%s is not a valid email address",
-  /* 92 */ "Email (%s) too short",
-  /* 93 */ "\"%s\" is not your email address",
-  /* 94 */ "Email (%s) must contain at least one at sign (@)",
-  /* 95 */ "Email (%s) can't end with an at sign (@)",
-  /* 96 */ "Email (%s) contains invalid characters",
-  /* 97 */ "Channel %s is not suspended.",
-  /* 98 */ "Channel %s is already suspended.",
-  /* 99 */ "Channel type: %s",
-  /* 100*/ "%s: unknown channel type",
-  /* 101*/ "Original founder: %s",
-  /* 102*/ "Added by: %s",
-  /* 103*/ "%s is already known on %s.",
-  /* 104*/ "Not removing channel owner %s from %s.",
-  /* 105*/ "Not removing channel master %s from %s.",
-  /* 106*/ "Can't find ban %s on %s.",
-  /* 107*/ "Your language is currently set to: %s.",
-  /* 108*/ "The following languages are currently known:",
-  /* 109*/ "Unknown language code: %s.",
-  /* 110*/ "Language       : %s",
-  /* 111*/ "Channel type for %s is: %s",
-  /* 112*/ "Statistics for %s:",
-  /* 113*/ "Date added: %s",
-  /* 114*/ "Since %s: maximum size %d, %d joins (%.1f joins/day).",
-  /* 115*/ "Last active: %s",
-  /* 116*/ "Your Q account is suspended.",
-  /* 117*/ "Reason: %s",
-  /* 118*/ "Expires: %s",
-  /* 119*/ "Too many users AUTH'd to this account.",
-  /* 120*/ "Duration must be between 1d and 1M.",
-  /* 121*/ "Disconnecting %s (authed as %s)",
-  /* 122*/ "User is already suspended.",
-  /* 123*/ "User %s is not suspended.",
-  /* 124*/ "Username:       Suspended: Email:                         Last user@host:",
-  /* 125*/ "Found over %d %s, truncating list.",
-  /* 126*/ "Found %u %s%s.",
-  /* 127*/ "Attention: Your Q account has been suspended. You are being disconnected.",
-  /* 128*/ "Username:       Flags:            Suspended: Email:                         Last user@host:",
-  /* 129*/ "Username:       Suspend type: Suspended by:   Date suspended: Expires:        Reason:",
-  /* 130*/ "Channel:                       Suspended by:   Date suspended: Reason:",
-  /* 131*/ "You cannot request ownership of %s as there is a channel %s present.",
-  /* 132*/ "You have been granted ownership of %s.",
-  /* 133*/ "#:  User:                                              Authed:         Disconnected:   Reason:",
-  /* 134*/ "Current modes on %s: %s",
-  /* 135*/ "Domain:             Users:  Flags:",
-  /* 136*/ "Sorry, no more accounts are allowed from this email domain.",
-  /* 137*/ "Password too weak - You need to avoid repeating characters, and have different character types (e.g. 1 number and 1 letter)",
-  /* 138*/ "User %s is not a master on %s - you must promote user to master status first.",
-  /* 139*/ "User %s is already an owner on %s.",
-  /* 140*/ "WARNING: This command will give COMPLETE control over %s to %s,\nincluding the ability to remove you as owner.  If you are sure you want to\ndo this, type: GIVEOWNER %s #%s %s",
-  /* 141*/ "Hash value incorrect, try again.",
-  /* 142*/ "Showing %s for last %s.",
-  /* 143*/ "Change your nickname to something with none of the following characters: `~^[]{}|_\\",
-  /* 144*/ "Invalid digest algorithm.",
-  /* 145*/ "Challenge has either not been requested or has expired.",
-  /* 146*/ "For security reasons it is not possible to give the owner flag to other users\nusing CHANLEV.  Use GIVEOWNER if you really wanted to do this.",
-  /* 147*/ "You must specify at least one valid flag to add.",
-  /* 148*/ "New ban is already contained within existing ban: %s",
-  /* 149*/ "New ban would replace at least one existing ban (%s), use UNBANMASK %s first if you want to set this ban.",
-  /* 150*/ "A temporary ban with this mask already exists, replacing it.",
-  /* 151*/ "That permanent ban already exists.",
-  /* 152*/ "That ban is already set with a longer duration.",
-  /* 153*/ "Replaced existing ban which was set with a shorter duration.",
-  /* 154*/ "Channel has too many user entries, aborting.",
-  /* 155*/ "No more bans are allowed on that channel.",
-  /* 156*/ "Warning: not removing registered ban %s from %s.",
-  /* 157*/ "Sorry, the registration service is unavailable to you at this time. Please try again later.", /* a deliberately vague message */
-  /* 158*/ "Too many accounts exist from this email address.",
-  /* 159*/ "That email address has been blocked.",
-  /* 160*/ "For more information, type HELP %s.",
-  /* 161*/ "Cannot send password for that account.",
-  /* 162*/ "The new email address is the same as current one.",
-  /* 163*/ "Supplied autolimit is invalid: %s",
-  /* 164*/ "This account has recently been modified. It will be unlocked on %s.",
-  /* 165*/ "That account is not locked.",
-  /* 166*/ "Your old account settings have been restored, please check your email.",
-  /* 167*/ "Bad reset code.",
-  /* 168*/ "WARNING: the selected algorithm is legacy functionality and is likely to be removed in the near future.",
-  /* 169*/ "Total: %d (owner: %d, master: %d, op: %d, voice: %d, known: %d, ban: %d).",
-  /* 170*/ "Pattern:                                           Created by:     Reason:                   Created:",
-  /* 171*/ "%-50s %-15s %-25s %s",
-  /* 172*/ "That pattern doesn't exist.",
-  /* 173*/ "That pattern already exists!",
-  /* 174*/ "Sorry, you can't use that email address.",
-  /* 175*/ "You do not have sufficient access to use %s on %s.",
-  /* 176*/ "No channel op events have been logged for %s.",
-  /* 177*/ "Channel op events on %s:\nNickname        Account used",
-  /* 178*/ "Warning: %s (%s@%s) attempted to auth with your password but you already had %d users authed to your account.",
-  /* 179*/ "Warning: %s (%s@%s) authed with your password.",
-  /* 180*/ "Resettable statistics reset for %s.",
-  /* 181*/ "The channel has been deleted since the last known user was removed.",
-  /* 182*/ "Done.  Flags for %s on %s are now: %s.",
-  /* 183*/ "Done.  User %s is no longer known on %s.",
-  /* 184*/ "No change - check that you didn't specify an impossible flag combination.",
-  /* 185*/ "Users currently on %s:\nNick            Username        Flags        Host",
-  /* 186*/ "Channel %s is currently empty.",
-  /* 187*/ "Total %d users: %d opped, %d voiced, %d others, %d with flags (%d ops, %d masters)"
-};
-
 void initmessages() {
   int i;
   int j;
diff --git a/chanserv/q9snprintf.c b/chanserv/q9snprintf.c
new file mode 100644 (file)
index 0000000..b57f069
--- /dev/null
@@ -0,0 +1,139 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include "../lib/sstring.h"
+
+#define MAXARGS 10
+
+struct bufs {
+  char *buf;
+  int capacity;
+  int len;
+};
+
+static int addchar(struct bufs *buf, char c) {
+  if(buf->len >= buf->capacity - 1)
+    return 0;
+
+  buf->buf[buf->len++] = c;
+
+  return 1;
+}
+
+static int addstr(struct bufs *buf, char *c) {
+  int remaining = buf->capacity - buf->len - 1;
+  char *p;
+
+  for(p=c;*p;p++) {
+    if(remaining-- <= 0)
+      return 0;
+
+    buf->buf[buf->len++] = *p;
+  }
+
+  return 1;
+}
+
+void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, va_list ap) {
+  struct bufs b;
+  const char *p;
+  char *c;
+  char convbuf[MAXARGS][512];
+
+  if(size == 0)
+    return;
+
+  {
+    int argno = 0;
+    int d, i;
+    char *s;
+    sstring *ss;
+    double f;
+
+    for(i=0;i<MAXARGS;i++)
+      convbuf[i][0] = '\0';
+
+    while(*args) {
+      switch(*args++) {
+        case 's':
+          s = va_arg(ap, char *);
+          snprintf(convbuf[argno++], sizeof(convbuf[0]), "%s", s);
+          break;
+        case 'S':
+          ss = va_arg(ap, sstring *);
+          snprintf(convbuf[argno++], sizeof(convbuf[0]), "%s", s?"(null)":ss->content);
+          break;
+        case 'd':
+          d = va_arg(ap, int);
+          snprintf(convbuf[argno++], sizeof(convbuf[0]), "%d", d);
+          break;
+        case 'g':
+          f = va_arg(ap, double);
+          snprintf(convbuf[argno++], sizeof(convbuf[0]), "%.1f", f);
+          break;
+      }
+    }
+  }
+
+  b.buf = buf;
+  b.capacity = size;
+  b.len = 0;
+
+  for(p=format;*p;p++) {
+    if(*p != '$') {
+      if(!addchar(&b, *p))
+        break;
+      continue;
+    }
+    p++;
+    if(*p == '\0')
+      break;
+    if(*p == '$') {
+      if(!addchar(&b, *p))
+        break;
+      continue;
+    }
+
+    c = NULL;
+    switch(*p) {
+/*
+      case 'C':
+        c = botname; break;
+      case 'N':
+        c = network; break;
+*/
+      case '0':
+      case '1':
+      case '2':
+      case '3':
+      case '4':
+      case '5':
+      case '6':
+      case '7':
+      case '8':
+      case '9':
+        c = convbuf[*p - '0']; break;
+      default:
+        c = "(bad format specifier)";
+    }
+    if(c)
+      if(!addstr(&b, c))
+        break;
+  }
+
+  buf[b.len] = '\0';
+
+  /* not required */
+  /*
+  buf[size-1] = '\0';
+  */
+}
+
+void q9snprintf(char *buf, size_t size, const char *format, const char *args, ...) {
+  va_list ap;
+
+  va_start(ap, args);
+  q9vsnprintf(buf, size, format, args, ap);
+  va_end(ap);
+}
index 13bf6002d5b2e2a1096cfe891d23356ea92a29b5..07b77c725c563ef66d4e4fb7e84ba4d584b55479 100644 (file)
@@ -42,7 +42,7 @@ int csu_domaillock(void *source, int cargc, char **cargv) {
       rup=findreguserbyID(mlp->createdby);
       strftime(timebuf,15,"%d/%m/%y %H:%M",gmtime(&mlp->created));
 
-      chanservstdmessage(sender, QM_MAILLOCKLINE, mlp->pattern->content, rup?rup->username:"??", mlp->reason?mlp->reason->content:"(none)", timebuf);
+      chanservsendmessage(sender, "%-50s %-15s %-25s %s", mlp->pattern->content, rup?rup->username:"??", mlp->reason?mlp->reason->content:"(none)", timebuf);
     }
   } else if(!strcasecmp(cargv[0], "-del")) {
     maillock *pmlp = NULL;