diff options
author | certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b <certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-07-04 20:28:26 +0000 |
---|---|---|
committer | certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b <certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-07-04 20:28:26 +0000 |
commit | b79837538f03ad47506abc53a86c7a54d90d4cf5 (patch) | |
tree | 61167019efc2c66f5746c8fdd058e73f5540ff06 | |
parent | 3323816264fc01ccfb455b61bf43cbe8621532cf (diff) |
Undoing last commit because it isn't needed.
git-svn-id: svn://svn.anope.org/anope/trunk@1081 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@805 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | Changes.lang | 11 | ||||
-rw-r--r-- | include/extern.h | 4 | ||||
-rw-r--r-- | include/services.h | 5 | ||||
-rw-r--r-- | lang/cat.l | 20 | ||||
-rw-r--r-- | lang/de.l | 34 | ||||
-rw-r--r-- | lang/en_us.l | 29 | ||||
-rw-r--r-- | lang/es.l | 20 | ||||
-rw-r--r-- | lang/fr.l | 20 | ||||
-rw-r--r-- | lang/gr.l | 20 | ||||
-rw-r--r-- | lang/hun.l | 20 | ||||
-rw-r--r-- | lang/it.l | 20 | ||||
-rw-r--r-- | lang/nl.l | 20 | ||||
-rw-r--r-- | lang/pl.l | 22 | ||||
-rw-r--r-- | lang/pt.l | 20 | ||||
-rw-r--r-- | lang/ru.l | 20 | ||||
-rw-r--r-- | lang/tr.l | 20 | ||||
-rw-r--r-- | src/mysql.c | 29 | ||||
-rw-r--r-- | src/sessions.c | 472 | ||||
-rw-r--r-- | src/tools/db-merger.c | 40 | ||||
-rw-r--r-- | version.log | 6 |
21 files changed, 521 insertions, 333 deletions
@@ -41,7 +41,6 @@ Provided by Anope Dev. <dev@anope.org> - 2006 06/21 F Syntax for NickServ SET MSG showed syntax for SET PRIVATE. [ #00] 06/26 F A few small bugs with module configure scripts. [ #00] 07/02 F Fixed readonly stuff on memoserv del. [#529] -07/04 F Rewrote exception system due to a bug we couldn't track down. [#491] Provided by ThaPrince <jon@vile.com> - 2006 05/19 A Plexus 3 support. [ #00] @@ -146,6 +145,7 @@ Provided by Anope Dev. <dev@anope.org> - 2005 Provided by Trystan <trystan@nomadirc.net> - 2005 11/19 F find_byuid for ircds which didnt give us a uid. [ #00] +01/22 F Updated config.guess and config.sub [ #00] Provided by Vladimir K. <wawaka@gmail.com> - 2005 12/11 F Enforcers had incorrect user when only user specified. [#410] diff --git a/Changes.lang b/Changes.lang index 3c20094af..bf8c6527b 100644 --- a/Changes.lang +++ b/Changes.lang @@ -4,19 +4,8 @@ Anope Version S V N INVALID_TARGET *** Mod Strings: -OPER_EXCEPTION_LIST_FORMAT -OPER_EXCEPTION_LIST_COLHEAD -OPER_EXCEPTION_DEL_SYNTAX -OPER_EXCEPTION_SYNTAX -OPER_EXCEPTION_VIEW_FORMAT *** Del Strings: -OPER_EXCEPTION_MOVE_SYNTAX -OPER_EXCEPTION_MOVED -OPER_EXCEPTION_DELETED_ONE -OPER_EXCEPTION_DELETED_SEVERAL -OPER_EXCEPTION_NO_SUCH_ENTRY - Anope Version 1.7.14 -------------------- diff --git a/include/extern.h b/include/extern.h index 488896779..ad6274754 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1016,7 +1016,7 @@ E void finish_sync(Server *serv, int sync_links); /**** sessions.c ****/ -E Exception *exceptionlist[1024]; +E Exception *exceptions; E int16 nexceptions; E Session *sessionlist[1024]; @@ -1038,7 +1038,7 @@ E void expire_exceptions(void); E Session *findsession(const char *host); E Exception *find_host_exception(const char *host); -E Exception *exception_add(User * u, const char *mask, const int limit, +E int exception_add(User * u, const char *mask, const int limit, const char *reason, const char *who, const time_t expires); diff --git a/include/services.h b/include/services.h index b40d7e785..2ee228233 100644 --- a/include/services.h +++ b/include/services.h @@ -1069,13 +1069,16 @@ struct newsitem_ { struct exception_ { - Exception *prev, *next; char *mask; /* Hosts to which this exception applies */ int limit; /* Session limit for exception */ char who[NICKMAX]; /* Nick of person who added the exception */ char *reason; /* Reason for exception's addition */ time_t time; /* When this exception was added */ time_t expires; /* Time when it expires. 0 == no expiry */ + int num; /* Position in exception list; used to track + * positions when deleting entries. It is + * symbolic and used internally. It is + * calculated at load time and never saved. */ }; /*************************************************************************/ diff --git a/lang/cat.l b/lang/cat.l index 9a9cbe230..bfac46693 100644 --- a/lang/cat.l +++ b/lang/cat.l @@ -3052,11 +3052,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [parametres] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametres] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiració] mascara límit raó OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mascara} + EXCEPTION DEL {mascara | llista} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE numero posició OPER_EXCEPTION_DISABLED Límits de sessions no disponibles. OPER_EXCEPTION_ALREADY_PRESENT @@ -3065,22 +3067,30 @@ OPER_EXCEPTION_TOO_MANY La llista d'excepcions al límit de sessiones esta plena! OPER_EXCEPTION_ADDED Límit de sessió per a %s establert a %d. +OPER_EXCEPTION_MOVED + Excepció per a %s (#%d) moguda a la posició %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + La instància no existeix (#%d) a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_NOT_FOUND %s no trobat a a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_NO_MATCH No existeixen instàncies similars a la llista d'excepcions al límit de sessions. OPER_EXCEPTION_DELETED %s instàncies esborrades de la llista d'excepcions al límit de sessions. +OPER_EXCEPTION_DELETED_ONE + 1 instància esborrada de la llista d'excepcions al límit de sessions. +OPER_EXCEPTION_DELETED_SEVERAL + %d instàncies esborrades de la llista d'excepcions al límit de sessions. OPER_EXCEPTION_LIST_HEADER llista d'excepcions al límit de sessions actual: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Límit Host + Num Límit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (per %s a %s; %s) + %3d. %s (per %s a %s; %s) Límit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Límit de sessió invàlid. Ha de ser un sencer vàlido més gran o igual a zero i mes petit que %d. @@ -2998,11 +2998,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [Parameter] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [Parameter] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+Zeit] Hostmaske Limit Grund OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {Hostmaske} + EXCEPTION DEL {Hostmaske | Liste} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE Nummer Position OPER_EXCEPTION_DISABLED Eingeschränkte Verbindungen sind deaktiviert. OPER_EXCEPTION_ALREADY_PRESENT @@ -3011,6 +3013,11 @@ OPER_EXCEPTION_TOO_MANY Die Liste für eingeschränkte Verbindungen ist voll! OPER_EXCEPTION_ADDED Verbindungslimit für %s geändert auf %d. +OPER_EXCEPTION_MOVED + DIe Exception für %s (#%d) wurde auf die %d Position verschoben. +OPER_EXCEPTION_NO_SUCH_ENTRY + Kein solcher Eintrag (#%d) in der Liste der Verbindungs- + einschränkungen. OPER_EXCEPTION_NOT_FOUND %s nicht gefunden in der Liste der Verbindungs- einschränkungen. @@ -3020,16 +3027,22 @@ OPER_EXCEPTION_NO_MATCH OPER_EXCEPTION_DELETED %s wurde von der Liste der Verbindungseinschränkungen entfernt. +OPER_EXCEPTION_DELETED_ONE + Es wurde 1 Eintrag von der Liste der Verbindungs- + einschränkungen entfernt. +OPER_EXCEPTION_DELETED_SEVERAL + Es wurden %d Einträge von der Liste der Verbindungs- + einschränkungen entfernt. OPER_EXCEPTION_LIST_HEADER Aktuelle Liste für eingeschränkte Verbindungen: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limit Host + Nummer Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (von %s am %s, %s) + %3d. %s (von %s am %s, %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Ungültige Verbindungseinschränkung. Es muss eine gültige Integer-Zahl sein, grösser oder gleich @@ -3069,9 +3082,10 @@ OPER_SESSION_VIEW_FORMAT OPER_HELP_EXCEPTION Syntax: EXCEPTION ADD [+Zeit] Hostmaske Limit Grund - EXCEPTION DEL {Hostmaske] - EXCEPTION LIST [Hostmaske] - EXCEPTION VIEW [Hostmaske] + EXCEPTION DEL {Hostmaske | Liste} + EXCEPTION MOVE Nummer Position + EXCEPTION LIST [Hostmaske | Liste] + EXCEPTION VIEW [Hostmaske | Liste] Erlaubt Services Administratoren, die Liste der Verbindungs- einschränkungen zu bearbeiten.Dadurch ist es möglich @@ -3098,6 +3112,10 @@ OPER_HELP_EXCEPTION EXCEPTION DEL entfernt den Host von der Liste. + EXCEPTION MOVE verschiebt den Eintrag mit der Nummer + auf die Position. Die Einträge dazwischen werden + hoch bzw runtergeschoben um die Lücken zu füllen. + EXCEPTION LIST und EXCEPTION VIEW zeigt alle aktuellen Verbindungseinschränkungen. Wird die optionale Hostmaske angegeben, werden nur die entsprechenden Einträge aus diff --git a/lang/en_us.l b/lang/en_us.l index a3dd37b35..5aae18c2d 100644 --- a/lang/en_us.l +++ b/lang/en_us.l @@ -2938,11 +2938,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiry] mask limit reason OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask} + EXCEPTION DEL {mask | list} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE num position OPER_EXCEPTION_DISABLED Session limiting is disabled. OPER_EXCEPTION_ALREADY_PRESENT @@ -2951,22 +2953,30 @@ OPER_EXCEPTION_TOO_MANY Session-limit exception list is full! OPER_EXCEPTION_ADDED Session limit for %s set to %d. +OPER_EXCEPTION_MOVED + Exception for %s (#%d) moved to position %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + No such entry (#%d) session-limit exception list. OPER_EXCEPTION_NOT_FOUND %s not found on session-limit exception list. OPER_EXCEPTION_NO_MATCH No matching entries on session-limit exception list. OPER_EXCEPTION_DELETED %s deleted from session-limit exception list. +OPER_EXCEPTION_DELETED_ONE + Deleted 1 entry from session-limit exception list. +OPER_EXCEPTION_DELETED_SEVERAL + Deleted %d entries from session-limit exception list. OPER_EXCEPTION_LIST_HEADER Current Session Limit Exception list: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limit Host + Num Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Invalid session limit. It must be a valid integer greater than or equal to zero and less than %d. @@ -3005,9 +3015,10 @@ OPER_SESSION_VIEW_FORMAT OPER_HELP_EXCEPTION Syntax: EXCEPTION ADD [+expiry] mask limit reason - EXCEPTION DEL {mask} - EXCEPTION LIST [mask] - EXCEPTION VIEW [mask] + EXCEPTION DEL {mask | list} + EXCEPTION MOVE num position + EXCEPTION LIST [mask | list] + EXCEPTION VIEW [mask | list] Allows Services admins to manipulate the list of hosts that have specific session limits - allowing certain machines, @@ -3028,6 +3039,8 @@ OPER_HELP_EXCEPTION unlimited session limit. See the AKILL help for details about the format of the optional expiry parameter. EXCEPTION DEL removes the given mask from the exception list. + EXCEPTION MOVE moves exception num to position. The + exceptions inbetween will be shifted up or down to fill the gap. EXCEPTION LIST and EXCEPTION VIEW show all current exceptions; if the optional mask is given, the list is limited to those exceptions matching the mask. The difference is that @@ -3026,11 +3026,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [parametros] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametros] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+expiracion] mascara limite razon OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mascara} + EXCEPTION DEL {mascara | lista} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE numero posicion OPER_EXCEPTION_DISABLED Limites de sesion no disponibles. OPER_EXCEPTION_ALREADY_PRESENT @@ -3039,22 +3041,30 @@ OPER_EXCEPTION_TOO_MANY La lista de excepciones al limite de sesiones esta llena! OPER_EXCEPTION_ADDED Limite de sesion para %s seteado a %d. +OPER_EXCEPTION_MOVED + Excepcion para %s (#%d) movido a la posicion %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + La instancia no existe (#%d) en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_NOT_FOUND %s no encontrado en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_NO_MATCH No existen instancias similares en la lista de excepciones al limite de sesiones. OPER_EXCEPTION_DELETED %s instancias borradas de la lista de excepciones al limite de sesiones. +OPER_EXCEPTION_DELETED_ONE + 1 instancia borrada de la lista de excepciones al limite de sesiones. +OPER_EXCEPTION_DELETED_SEVERAL + %d instancias borradas de la lista de excepciones al limite de sesiones. OPER_EXCEPTION_LIST_HEADER Lista de excepciones al limite de sesiones actual: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limite Host + Num Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de sesion invalido. Debe ser un entero valido mayor o igual a cero y menor a %d. @@ -3076,11 +3076,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [paramètres] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paramètres] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+échéance] mask limite raison OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask} + EXCEPTION DEL {mask | liste} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE num position OPER_EXCEPTION_DISABLED La limitation de sessions est désactivée. OPER_EXCEPTION_ALREADY_PRESENT @@ -3089,22 +3091,30 @@ OPER_EXCEPTION_TOO_MANY La liste des exceptions à la limitation de sessions est pleine! OPER_EXCEPTION_ADDED La limite de sessions de %s est maintenant de %d. +OPER_EXCEPTION_MOVED + L'exception pour %s (#%d) a été déplacée à la position %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + L'entrée %d n'existe pas sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_NOT_FOUND %s non trouvé sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_NO_MATCH Aucune entrée correspondante sur la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_DELETED %s supprimé de la liste des exceptions à la limitation de sessions. +OPER_EXCEPTION_DELETED_ONE + 1 entrée supprimée de la liste des exceptions à la limitation de sessions. +OPER_EXCEPTION_DELETED_SEVERAL + %d entrées supprimées de la liste des exceptions à la limitation de sessions. OPER_EXCEPTION_LIST_HEADER Liste actuelle des exceptions à la limitation de sessions: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limite Host + Num Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (par %s le %s; %s) + %3d. %s (par %s le %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de session invalide. Elle doit être un entier valide supérieur ou égal à zero et plus petit que %d. @@ -3054,11 +3054,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+÷ñüíïò ëÞîçò] ìÜóêá üñéï ëüãïò OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {ìÜóêá} + EXCEPTION DEL {ìÜóêá | ëßóôá} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE íïýìåñï èÝóç OPER_EXCEPTION_DISABLED Ç Session limiting åíôïëÞ åßíáé áðåíåñãïðïéçìÝíç. OPER_EXCEPTION_ALREADY_PRESENT @@ -3067,22 +3069,30 @@ OPER_EXCEPTION_TOO_MANY Ç ëßóôá Session-limit exception åßíáé full! OPER_EXCEPTION_ADDED Session limit ãéá ôïí %s ñõèìßóôçêå óå %d. +OPER_EXCEPTION_MOVED + Exception ãéá %s (#%d) ìåôáêéíÞèçêå óôç èÝóç %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + Äåí âñÝèçêå èÝóç (#%d) óôç ëßóôá session-limit exception. OPER_EXCEPTION_NOT_FOUND %s äåí âñÝèçêå óôçí ëßóôá session-limit exception. OPER_EXCEPTION_NO_MATCH Äåí âñÝèçêáí èÝóåéò óôçí ëßóôá session-limit exception. OPER_EXCEPTION_DELETED %s äéáãñÜöçêå áðü ôçí ëßóôá session-limit exception. +OPER_EXCEPTION_DELETED_ONE + ÄéáãñÜöçêå 1 èÝóç áðü ôçí ëßóôá session-limit exception. +OPER_EXCEPTION_DELETED_SEVERAL + ÄéáãñÜöçêáí %d èÝóåéò áðü ôçí ëßóôá session-limit exception. OPER_EXCEPTION_LIST_HEADER Ç Ýùò ôþñá ëßóôá Session Limit Exception åßíáé ïé åîÞò: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limit Host + Íïõ Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT ËÜèïò session limit. ÐñÝðåé íá åßíáé ëÜèïò ï integer greater Þ ðñÝðåé íá åßíáé ìåôáîý ìçäÝí êáé %d. diff --git a/lang/hun.l b/lang/hun.l index 07ed55339..04a7c575e 100644 --- a/lang/hun.l +++ b/lang/hun.l @@ -2989,11 +2989,13 @@ MODULE_HELP_HEADER # EXCEPTION válaszok OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [paraméterek] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paraméterek] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+elévülés] maszk korlát indok OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {maszk} + EXCEPTION DEL {maszk | list} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE Szám helyzet OPER_EXCEPTION_DISABLED Session korlátozás tiltva. OPER_EXCEPTION_ALREADY_PRESENT @@ -3002,22 +3004,30 @@ OPER_EXCEPTION_TOO_MANY Session-korlát lista megtelt! OPER_EXCEPTION_ADDED Session korlát %s részére %d-re állítva. +OPER_EXCEPTION_MOVED + %s kivétel (#%d) áthelyezve a %d pozicíóba. +OPER_EXCEPTION_NO_SUCH_ENTRY + Nincs bejegyezve (#%d) session-korlát a kivétel listán. OPER_EXCEPTION_NOT_FOUND %s nem található a session-korlát kivétel listán. OPER_EXCEPTION_NO_MATCH Nincs ilyen bejegyzés a session-korlát kivétel listán. OPER_EXCEPTION_DELETED %s törölve a session-korlát kivétel listáról. +OPER_EXCEPTION_DELETED_ONE + Törölve 1 bejegyzés a session-korlát kivétel listáról. +OPER_EXCEPTION_DELETED_SEVERAL + Törölve %d bejegyzés a session-korlát kivétel listáról. OPER_EXCEPTION_LIST_HEADER Aktuális Session korlát kivétel lista: # mask, korlát OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Korlát Host + Szám Korlát Host # maszk, set-by, set-idõ,lejárat, korlát, Indok OPER_EXCEPTION_VIEW_FORMAT - %s (%s által, ekkor: %s; %s) + %3d. %s (%s által, ekkor: %s; %s) Korlát: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Érvénytelen session korlát. Érvényes számnak kell lennie @@ -2948,11 +2948,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [parametri] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametri] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+durata] mask limite motivo OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask} + EXCEPTION DEL {mask | lista} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE num posizione OPER_EXCEPTION_DISABLED Il limite delle sessioni è disabilitato. OPER_EXCEPTION_ALREADY_PRESENT @@ -2961,22 +2963,30 @@ OPER_EXCEPTION_TOO_MANY La lista delle eccezioni è piena! OPER_EXCEPTION_ADDED Il limite di sessioni per %s è stato impostato a %d. +OPER_EXCEPTION_MOVED + L'eccezione per %s (numero %d) è stata spostata alla posizione %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + Il record specificato (%d) non esiste nella lista delle eccezioni. OPER_EXCEPTION_NOT_FOUND Impossibile trovare %s nella lista delle eccezioni. OPER_EXCEPTION_NO_MATCH Nessun record corrispondente nella lista delle eccezioni. OPER_EXCEPTION_DELETED %s eliminato dalla lista delle eccezioni. +OPER_EXCEPTION_DELETED_ONE + Eliminato 1 record dalla lista delle eccezioni. +OPER_EXCEPTION_DELETED_SEVERAL + Eliminati %d record dalla lista delle eccezioni. OPER_EXCEPTION_LIST_HEADER Lista delle eccezioni attuale: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limite Host + Num Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite delle sessioni non valido. Deve essere un numero intero maggiore o uguale a zero e minore di %d. @@ -3008,11 +3008,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [paramenters] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [paramenters] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+verloop] mask limiet reden OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask} + EXCEPTION DEL {mask | lijst} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE nr positie OPER_EXCEPTION_DISABLED Sessie limitering is tijdelijk uitgeschakeld. OPER_EXCEPTION_ALREADY_PRESENT @@ -3021,22 +3023,30 @@ OPER_EXCEPTION_TOO_MANY Sessie limiet uitzonderingenlijst is vol! OPER_EXCEPTION_ADDED Sessie limiet voor %s veranderd in %d. +OPER_EXCEPTION_MOVED + Uitzondering voor %s (#%d) verplaatst naar positie %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + #%d bestaat niet op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_NOT_FOUND %s niet gevonden op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_NO_MATCH Geen overeenkomsten op de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_DELETED %s verwijderd van de sessie limiet uitzonderingenlijst. +OPER_EXCEPTION_DELETED_ONE + 1 uitzondering verwijderd van de sessie limiet uitzonderingenlijst. +OPER_EXCEPTION_DELETED_SEVERAL + %d uitzonderingen verwijderd van de sessie limiet uitzonderingenlijst. OPER_EXCEPTION_LIST_HEADER Huidige Sessie Limiet Uitzonderingenlijst: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limiet Host + Nr Limiet Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (door %s op %s; %s) + %3d. %s (door %s op %s; %s) Limiet: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Ongeldige sessie limiet. Het moet een geldige integer groter dan of gelijk aan nul en kleiner dan %d. @@ -3203,11 +3203,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [params] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [params] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+czastrwania] maska limit powód OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {maska} + EXCEPTION DEL {maska | lista} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE nr pozycja OPER_EXCEPTION_DISABLED Limitowanie sesji jest wy³±czone. OPER_EXCEPTION_ALREADY_PRESENT @@ -3216,6 +3218,11 @@ OPER_EXCEPTION_TOO_MANY Lista wyj±tków limitów sesji jest pe³na! OPER_EXCEPTION_ADDED Limit sesji dla %s zmieniono na %d. +OPER_EXCEPTION_MOVED + Wyj±tek dla %s (#%d) przeniesiono + na pozycje %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + No such entry (#%d) session-limit exception list. OPER_EXCEPTION_NOT_FOUND %s nie znaleziono na li¶cie wyj±tków limitów sesji. @@ -3224,16 +3231,21 @@ OPER_EXCEPTION_NO_MATCH sesji. OPER_EXCEPTION_DELETED %s usuniêto z listy wyj±tków limitów sesji. +OPER_EXCEPTION_DELETED_ONE + Usuniêto 1 wpis z listy wyj±tków limitów sesji. +OPER_EXCEPTION_DELETED_SEVERAL + Usuniêto %d wpisy(ów) z listy wyj±tków limitów + sesji. OPER_EXCEPTION_LIST_HEADER Aktualna lista wyj±tków limitów sesji: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limit Host + Nr Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (przez %s na %s; %s) + %3d. %s (przez %s na %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Nieprawid³owy limit sesji. Musi byæ liczb± dodatni±, @@ -2963,11 +2963,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [parâmetros] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parâmetros] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+tempo] máscara limite motivo OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {máscara} + EXCEPTION DEL {máscara | lista} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE núm posição OPER_EXCEPTION_DISABLED Opção de limite de sessões desabilitada. OPER_EXCEPTION_ALREADY_PRESENT @@ -2976,22 +2978,30 @@ OPER_EXCEPTION_TOO_MANY Lista de limite de sessões está cheia! OPER_EXCEPTION_ADDED Limite de sessões para %s é agora de %d. +OPER_EXCEPTION_MOVED + Sessão para %s (#%d) alterada para a posição %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + Nenhuma entrada equivalente (#%d) na lista de limite de sessões. OPER_EXCEPTION_NOT_FOUND %s não encontrado na lista de limite de sessões. OPER_EXCEPTION_NO_MATCH Nenhum resultado encontrado na lista de limite de sessões. OPER_EXCEPTION_DELETED %s removido da lista de limite de sessões. +OPER_EXCEPTION_DELETED_ONE + Removida 1 entrada da lista de limite de sessões. +OPER_EXCEPTION_DELETED_SEVERAL + Removidas %d entradas da lista de limite de sessões. OPER_EXCEPTION_LIST_HEADER Atual lista de Limite de sessões: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limite Host + Núm Limite Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (por %s em %s; %s) + %3d. %s (por %s em %s; %s) Limite: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Limite de sessão inválida. O limite deve ser um número inteiro maior ou igual a zero e menor que %d. @@ -3000,11 +3000,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [ïàðàìåòðû] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [ïàðàìåòðû] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+âðåìÿ èñòå÷åíèÿ] ìàñêà ëèìèò ïðè÷èíà OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {ìàñêà} + EXCEPTION DEL {ìàñêà | list} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE íîìåð ïîçèöèÿ OPER_EXCEPTION_DISABLED Îãðàíè÷åíèå ñåññèé îòêëþ÷åíî. OPER_EXCEPTION_ALREADY_PRESENT @@ -3013,22 +3015,30 @@ OPER_EXCEPTION_TOO_MANY Ñïèñîê èñêëþ÷åíèé èç ëèìèòà ñåññèé ïåðåïîëíåí! OPER_EXCEPTION_ADDED Ëèìèò ñåññèé äëÿ %s óñòàíîâëåí â %d. +OPER_EXCEPTION_MOVED + Èñêëþ÷åíèå äëÿ %s (#%d) ïåðåìåùåíî â ïîçèöèþ %d. +OPER_EXCEPTION_NO_SUCH_ENTRY + Íåò òàêîé çàïèñè (#%d) â ñïèñêå èñêëþ÷åíèé èç ëèìèòâ ñåññèé. OPER_EXCEPTION_NOT_FOUND %s íå íàéäåí â ñïèñêå èñêëþ÷åíèé èç ëèìèò ñåññèé. OPER_EXCEPTION_NO_MATCH Íåò òàêèõ çíà÷åíèé â ñïèñêå èñêëþ÷åíèé èç ëèìèòà ñåññèé. OPER_EXCEPTION_DELETED %s óäàëåí èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. +OPER_EXCEPTION_DELETED_ONE + Óäàëåíà 1 çàïèñü èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. +OPER_EXCEPTION_DELETED_SEVERAL + Óäàëåíî %d çàïèñåé èç ñïèñêà èñêëþ÷åíèé èç ëèìèòà ñåññèé. OPER_EXCEPTION_LIST_HEADER Òåêóùèé ñïèñîê èñêëþ÷åíèé èç ëèìèòà ñåññèé: # ìàñêà, ëèìèò OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Ëèìèò Õîñò + Íîìåð Ëèìèò Õîñò # ìåñêà, êåì óñòàíîâëåíî, êîãäà óñòàíîâëåíî, êîãäà èñòåêàåò, ëèìèò, ïðè÷èíà OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Ëèìèò: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Íåêîððåêòíûé ëèìèò ñåññèé. Îí äîëæåí áûòü öåëûì ÷èñëîì áîëüøå èëè ðàâíûì íóëÿ è ìåíüøå %d. @@ -3047,11 +3047,13 @@ MODULE_HELP_HEADER # EXCEPTION responses OPER_EXCEPTION_SYNTAX - EXCEPTION {ADD | DEL | LIST | VIEW} [parametreler] + EXCEPTION {ADD | DEL | MOVE | LIST | VIEW} [parametreler] OPER_EXCEPTION_ADD_SYNTAX EXCEPTION ADD [+zamanaþýmý] mask limit sebep OPER_EXCEPTION_DEL_SYNTAX - EXCEPTION DEL {mask} + EXCEPTION DEL {mask | liste} +OPER_EXCEPTION_MOVE_SYNTAX + EXCEPTION MOVE num pozisyon OPER_EXCEPTION_DISABLED Session limit koyma devre dýþý. OPER_EXCEPTION_ALREADY_PRESENT @@ -3060,22 +3062,30 @@ OPER_EXCEPTION_TOO_MANY Session-limit exception listesi dolu! OPER_EXCEPTION_ADDED %s için session limit %d olarak deðiþtirildi. +OPER_EXCEPTION_MOVED + %s (#%d) için exception %d pozisyonuyla deðiþtirildi. +OPER_EXCEPTION_NO_SUCH_ENTRY + (#%d) böyle bir kayýt yok. session-limit exception listesi. OPER_EXCEPTION_NOT_FOUND %s session-limit exception listesinde bulunamadý. OPER_EXCEPTION_NO_MATCH session-limit exception listesinde uyuþan kayýt bulunamadý. OPER_EXCEPTION_DELETED %s session-limit exception listesinden silindi. +OPER_EXCEPTION_DELETED_ONE + Session-limit exception listesinden 1 kayýt silindi. +OPER_EXCEPTION_DELETED_SEVERAL + Session-limit exception listesinden %d kayýt silindi. OPER_EXCEPTION_LIST_HEADER Þu anki Session Limit Exception listesi: # mask, limit OPER_EXCEPTION_LIST_FORMAT - %4d %s + %3d %4d %s OPER_EXCEPTION_LIST_COLHEAD - Limit Host + Sayý Limit Host # mask, set-by, set-time, expires, limit, reason OPER_EXCEPTION_VIEW_FORMAT - %s (by %s on %s; %s) + %3d. %s (by %s on %s; %s) Limit: %-4d - %s OPER_EXCEPTION_INVALID_LIMIT Geçersiz session limiti. Sýfýrdan büyük yada eþit ve %d den az bir geçerli tamsayý olmalýdýr. diff --git a/src/mysql.c b/src/mysql.c index 889dcd40d..af319d5b6 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -983,13 +983,10 @@ void db_mysql_load_news(void) mysql_free_result(mysql_res); } -#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31)) - void db_mysql_load_exceptions(void) { char sqlcmd[MAX_SQL_BUF]; - Exception *exception; - int index; + int j; if (!do_mysql) return; @@ -1003,26 +1000,20 @@ void db_mysql_load_exceptions(void) } mysql_res = mysql_store_result(mysql); nexceptions = mysql_num_rows(mysql_res); - exception = scalloc(sizeof(Exception), 1); + exceptions = scalloc(sizeof(Exception) * nexceptions, 1); + j = 0; while ((mysql_row = mysql_fetch_row(mysql_res))) { - exception->mask = sstrdup(mysql_row[0]); - exception->limit = atoi(mysql_row[1]); - snprintf(exception->who, NICKMAX, "%s", mysql_row[2]); - exception->reason = sstrdup(mysql_row[3]); - exception->time = atoi(mysql_row[4]); - exception->expires = atoi(mysql_row[5]); - index = HASH(exception->mask); - exception->prev = NULL; - exception->next = exceptionlist[index]; - if (exception->next) - exception->next->prev = exception; - exceptionlist[index] = exception; + exceptions[j].mask = sstrdup(mysql_row[0]); + exceptions[j].limit = atoi(mysql_row[1]); + snprintf(exceptions[j].who, NICKMAX, "%s", mysql_row[2]); + exceptions[j].reason = sstrdup(mysql_row[3]); + exceptions[j].time = atoi(mysql_row[4]); + exceptions[j].expires = atoi(mysql_row[5]); + j++; } mysql_free_result(mysql_res); } -#undef HASH - #define HASH(host) ((tolower((host)[0])&31)<<5 | (tolower((host)[1])&31)) void db_mysql_load_os_dbase(void) diff --git a/src/sessions.c b/src/sessions.c index 29bb4b5f4..2bf0605ea 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -47,12 +47,6 @@ * exceptions. Comments and suggestions are more than welcome! * * -TheShadow (02 April 1999) - * - * The whole exception system has been rewritten to use linked list instead of - * an array due to a bug we couldn't track down. We don't need the numerical - * system anymore, it's not necessary to delete ranges. - * - * -Certus (04 July 2006) */ /*************************************************************************/ @@ -66,82 +60,10 @@ Session *sessionlist[1024]; int32 nsessions = 0; -Exception *exceptionlist[1024]; +Exception *exceptions = NULL; int16 nexceptions = 0; /*************************************************************************/ -/************************ Exception Manipulation *************************/ -/*************************************************************************/ - -Exception *exception_add(User * u, const char *mask, const int limit, - const char *reason, const char *who, - const time_t expires) -{ - int i, index; - Exception *exception, *ptr, *prev; - - /* Check if an exception already exists for this mask */ - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - if (!stricmp(mask, exception->mask)) { - if (exception->limit != limit) { - exception->limit = limit; - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, - mask, exception->limit); - return NULL; - } else { - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, - mask); - return NULL; - } - } - } - } - - nexceptions++; - exception = scalloc(sizeof(Exception), 1); - - exception->mask = sstrdup(mask); - exception->limit = limit; - exception->reason = sstrdup(reason); - exception->time = time(NULL); - strscpy(exception->who, who, NICKMAX); - exception->expires = expires; - - index = HASH(mask); /* bang! into the list! */ - - exception->prev = NULL; - exception->next = exceptionlist[index]; - if (exception->next) - exception->next->prev = exception; - exceptionlist[index] = exception; - - return exception; -} - -/*************************************************************************/ - -static int exception_del(Exception *exception) -{ - /* Remove the exception from the list */ - if (exception->next) - exception->next->prev = exception->prev; - if (exception->prev) - exception->prev->next = exception->next; - else - exceptionlist[HASH(exception->mask)] = exception->next; - - free(exception->mask); - free(exception->reason); - free(exception); - nexceptions--; - - return 1; -} - -/*************************************************************************/ /****************************** Statistics *******************************/ /*************************************************************************/ @@ -164,18 +86,14 @@ void get_session_stats(long *nrec, long *memuse) void get_exception_stats(long *nrec, long *memuse) { - Exception *exception; long mem; int i; mem = sizeof(Exception) * nexceptions; - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - mem += strlen(exception->mask) + 1; - mem += strlen(exception->reason) + 1; - } + for (i = 0; i < nexceptions; i++) { + mem += strlen(exceptions[i].mask) + 1; + mem += strlen(exceptions[i].reason) + 1; } - *nrec = nexceptions; *memuse = mem; } @@ -410,20 +328,22 @@ void del_session(const char *host) void expire_exceptions(void) { int i; - Exception *exception, *tmpexc; time_t now = time(NULL); - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = tmpexc) { - tmpexc = exception->next; - if (exception->expires == 0 || exception->expires > now) - continue; - if (WallExceptionExpire) - anope_cmd_global(s_OperServ, - "Session limit exception for %s has expired.", - exception->mask); - exception_del(exception); - } + for (i = 0; i < nexceptions; i++) { + if (exceptions[i].expires == 0 || exceptions[i].expires > now) + continue; + if (WallExceptionExpire) + anope_cmd_global(s_OperServ, + "Session limit exception for %s has expired.", + exceptions[i].mask); + free(exceptions[i].mask); + free(exceptions[i].reason); + nexceptions--; + memmove(exceptions + i, exceptions + i + 1, + sizeof(Exception) * (nexceptions - i)); + exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); + i--; } } @@ -432,12 +352,10 @@ void expire_exceptions(void) Exception *find_host_exception(const char *host) { int i; - Exception *exception; - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - if (match_wild_nocase(exception->mask, host)) - return exception; + for (i = 0; i < nexceptions; i++) { + if (match_wild_nocase(exceptions[i].mask, host)) { + return &exceptions[i]; } } @@ -460,7 +378,7 @@ Exception *find_host_exception(const char *host) void load_exceptions() { dbFILE *f; - int i, index; + int i; uint16 n; uint16 tmp16; uint32 tmp32; @@ -474,31 +392,21 @@ void load_exceptions() case 7: SAFE(read_int16(&n, f)); nexceptions = n; + exceptions = scalloc(sizeof(Exception) * nexceptions, 1); if (!nexceptions) { close_db(f); return; } for (i = 0; i < nexceptions; i++) { - - Exception *exception = scalloc(sizeof(Exception), 1); - - SAFE(read_string(&exception->mask, f)); + SAFE(read_string(&exceptions[i].mask, f)); SAFE(read_int16(&tmp16, f)); - exception->limit = tmp16; - SAFE(read_buffer(exception->who, f)); - SAFE(read_string(&exception->reason, f)); + exceptions[i].limit = tmp16; + SAFE(read_buffer(exceptions[i].who, f)); + SAFE(read_string(&exceptions[i].reason, f)); SAFE(read_int32(&tmp32, f)); - exception->time = tmp32; + exceptions[i].time = tmp32; SAFE(read_int32(&tmp32, f)); - exception->expires = tmp32; - - index = HASH(exception->mask); - - exception->prev = NULL; - exception->next = exceptionlist[index]; - if (exception->next) - exception->next->prev = exception; - exceptionlist[index] = exception; + exceptions[i].expires = tmp32; } break; @@ -530,22 +438,19 @@ void save_exceptions() { dbFILE *f; int i; - Exception *exception; static time_t lastwarn = 0; if (! (f = open_db(s_OperServ, ExceptionDBName, "w", EXCEPTION_VERSION))) return; SAFE(write_int16(nexceptions, f)); - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - SAFE(write_string(exception->mask, f)); - SAFE(write_int16(exception->limit, f)); - SAFE(write_buffer(exception->who, f)); - SAFE(write_string(exception->reason, f)); - SAFE(write_int32(exception->time, f)); - SAFE(write_int32(exception->expires, f)); - } + for (i = 0; i < nexceptions; i++) { + SAFE(write_string(exceptions[i].mask, f)); + SAFE(write_int16(exceptions[i].limit, f)); + SAFE(write_buffer(exceptions[i].who, f)); + SAFE(write_string(exceptions[i].reason, f)); + SAFE(write_int32(exceptions[i].time, f)); + SAFE(write_int32(exceptions[i].expires, f)); } close_db(f); } @@ -558,20 +463,156 @@ void save_rdb_exceptions() { #ifdef USE_RDB int i; - Exception *exception; + Exception *e; if (!rdb_open()) return; rdb_clear_table("anope_os_exceptions"); - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - rdb_save_exceptions(exception); - } + for (i = 0; i < nexceptions; i++) { + e = &exceptions[i]; + rdb_save_exceptions(e); } rdb_close(); #endif } +/*************************************************************************/ +/************************ Exception Manipulation *************************/ +/*************************************************************************/ + +int exception_add(User * u, const char *mask, const int limit, + const char *reason, const char *who, + const time_t expires) +{ + int i; + + /* Check if an exception already exists for this mask */ + for (i = 0; i < nexceptions; i++) { + if (!stricmp(mask, exceptions[i].mask)) { + if (exceptions[i].limit != limit) { + exceptions[i].limit = limit; + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, + mask, exceptions[i].limit); + return -2; + } else { + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, + mask); + return -1; + } + } + } + + nexceptions++; + exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); + + exceptions[nexceptions - 1].mask = sstrdup(mask); + exceptions[nexceptions - 1].limit = limit; + exceptions[nexceptions - 1].reason = sstrdup(reason); + exceptions[nexceptions - 1].time = time(NULL); + strscpy(exceptions[nexceptions - 1].who, who, NICKMAX); + exceptions[nexceptions - 1].expires = expires; + exceptions[nexceptions - 1].num = nexceptions - 1; + + return 1; +} + +/*************************************************************************/ + +static int exception_del(const int index) +{ + if (index < 0 || index >= nexceptions) + return 0; + + free(exceptions[index].mask); + free(exceptions[index].reason); + nexceptions--; + memmove(exceptions + index, exceptions + index + 1, + sizeof(Exception) * (nexceptions - index)); + exceptions = srealloc(exceptions, sizeof(Exception) * nexceptions); + + return 1; +} + +/* We use the "num" property to keep track of the position of each exception + * when deleting using ranges. This is because an exception's position changes + * as others are deleted. The positions will be recalculated once the process + * is complete. -TheShadow + */ + +static int exception_del_callback(User * u, int num, va_list args) +{ + int i; + int *last = va_arg(args, int *); + + *last = num; + for (i = 0; i < nexceptions; i++) { + if (num - 1 == exceptions[i].num) + break; + } + if (i < nexceptions) + return exception_del(i); + else + return 0; +} + +static int exception_list(User * u, const int index, int *sent_header) +{ + if (index < 0 || index >= nexceptions) + return 0; + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); + *sent_header = 1; + } + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, index + 1, + exceptions[index].limit, exceptions[index].mask); + return 1; +} + +static int exception_list_callback(User * u, int num, va_list args) +{ + int *sent_header = va_arg(args, int *); + + return exception_list(u, num - 1, sent_header); +} + +static int exception_view(User * u, const int index, int *sent_header) +{ + char timebuf[32], expirebuf[256]; + struct tm tm; + time_t t = time(NULL); + + if (index < 0 || index >= nexceptions) + return 0; + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + *sent_header = 1; + } + + tm = *localtime(exceptions[index].time ? &exceptions[index].time : &t); + strftime_lang(timebuf, sizeof(timebuf), + u, STRFTIME_SHORT_DATE_FORMAT, &tm); + + expire_left(u->na, expirebuf, sizeof(expirebuf), + exceptions[index].expires); + + notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, + index + 1, exceptions[index].mask, + *exceptions[index].who ? + exceptions[index].who : "<unknown>", + timebuf, expirebuf, exceptions[index].limit, + exceptions[index].reason); + return 1; +} + +static int exception_view_callback(User * u, int num, va_list args) +{ + int *sent_header = va_arg(args, int *); + + return exception_view(u, num - 1, sent_header); +} /*************************************************************************/ @@ -588,6 +629,9 @@ void save_rdb_exceptions() * Syntax: EXCEPTION VIEW [mask] * Displays detailed information about each exception or those matching * mask. + * + * Syntax: EXCEPTION MOVE num position + * Moves the exception at position num to position. */ int do_exception(User * u) @@ -607,11 +651,11 @@ int do_exception(User * u) cmd = ""; if (stricmp(cmd, "ADD") == 0) { - /* gotta keep this check because of the dbs :( -Certus */ if (nexceptions >= 32767) { notice_lang(s_OperServ, u, OPER_EXCEPTION_TOO_MANY); return MOD_CONT; } + mask = strtok(NULL, " "); if (mask && *mask == '+') { expiry = mask; @@ -643,27 +687,24 @@ int do_exception(User * u) MaxSessionLimit); return MOD_CONT; - } else { /* finally when can add it */ - Exception *exception; - + } else { if (strchr(mask, '!') || strchr(mask, '@')) { notice_lang(s_OperServ, u, OPER_EXCEPTION_INVALID_HOSTMASK); return MOD_CONT; } - exception = exception_add(u, mask, limit, reason, u->nick, expires); + x = exception_add(u, mask, limit, reason, u->nick, expires); - if (exception) - notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, limit); + if (x == 1) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, + limit); + } if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); } } else if (stricmp(cmd, "DEL") == 0) { - Exception *exception; - int deleted = 0; - mask = strtok(NULL, " "); if (!mask) { @@ -672,76 +713,127 @@ int do_exception(User * u) return MOD_CONT; } - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - if (!stricmp(mask, exception->mask)) { - exception_del(exception); - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, mask); + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + int count, deleted, last = -1; + deleted = + process_numlist(mask, &count, exception_del_callback, u, + &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_OperServ, u, + OPER_EXCEPTION_NO_SUCH_ENTRY, last); + } else { + notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); + } + } else if (deleted == 1) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_SEVERAL, + deleted); + } + } else { + int deleted = 0; + + for (i = 0; i < nexceptions; i++) { + if (stricmp(mask, exceptions[i].mask) == 0) { + exception_del(i); + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, + mask); deleted = 1; break; } } + if (!deleted && i == nexceptions) + notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); } - if (!deleted) - notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); + /* Renumber the exception list. I don't believe in having holes in + * lists - it makes code more complex, harder to debug and we end up + * with huge index numbers. Imho, fixed numbering is only beneficial + * when one doesn't have range capable manipulation. -TheShadow */ + + for (i = 0; i < nexceptions; i++) + exceptions[i].num = i; if (readonly) notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else if (stricmp(cmd, "MOVE") == 0) { + Exception *exception; + char *n1str = strtok(NULL, " "); /* From position */ + char *n2str = strtok(NULL, " "); /* To position */ + int n1, n2; + + if (!n2str) { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_MOVE_SYNTAX); + return MOD_CONT; + } + + n1 = atoi(n1str) - 1; + n2 = atoi(n2str) - 1; + + if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions) + && (n1 != n2)) { + exception = scalloc(sizeof(Exception), 1); + memcpy(exception, &exceptions[n1], sizeof(Exception)); + + if (n1 < n2) { + /* Shift upwards */ + memmove(&exceptions[n1], &exceptions[n1 + 1], + sizeof(Exception) * (n2 - n1)); + memmove(&exceptions[n2], exception, sizeof(Exception)); + } else { + /* Shift downwards */ + memmove(&exceptions[n2 + 1], &exceptions[n2], + sizeof(Exception) * (n1 - n2)); + memmove(&exceptions[n2], exception, sizeof(Exception)); + } + + free(exception); + notice_lang(s_OperServ, u, OPER_EXCEPTION_MOVED, + exceptions[n1].mask, n1 + 1, n2 + 1); + + /* Renumber the exception list. See the DEL block above for why. */ + for (i = 0; i < nexceptions; i++) + exceptions[i].num = i; + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_MOVE_SYNTAX); + } } else if (stricmp(cmd, "LIST") == 0) { int sent_header = 0; - Exception *exception; - expire_exceptions(); mask = strtok(NULL, " "); - - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - if (!mask || match_wild_nocase(mask, exception->mask)) { - if (!sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); - sent_header = 1; - } - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, - exception->limit, exception->mask); - } + if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, exception_list_callback, u, + &sent_header); + } else { + for (i = 0; i < nexceptions; i++) { + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) + exception_list(u, i, &sent_header); } } - if (!sent_header) notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); } else if (stricmp(cmd, "VIEW") == 0) { int sent_header = 0; - Exception *exception; - char timebuf[32], expirebuf[256]; - struct tm tm; - time_t t = time(NULL); - expire_exceptions(); mask = strtok(NULL, " "); - - for (i = 0; i < 1024; i++) { - for (exception = exceptionlist[i]; exception; exception = exception->next) { - if (!mask || match_wild_nocase(mask, exception->mask)) { - if (!sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - sent_header = 1; - } - tm = *localtime(exception->time ? &exception->time : &t); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_SHORT_DATE_FORMAT, &tm); - expire_left(u->na, expirebuf, sizeof(expirebuf), exception->expires); - notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, exception->mask, - exception->who ? exception->who : "<unknown>", timebuf, expirebuf, - exception->limit, exception->reason); - } + if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, exception_view_callback, u, + &sent_header); + } else { + for (i = 0; i < nexceptions; i++) { + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) + exception_view(u, i, &sent_header); } } - if (!sent_header) notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c index 030448b1b..4e9fde1df 100644 --- a/src/tools/db-merger.c +++ b/src/tools/db-merger.c @@ -1,34 +1,3 @@ -/* - * IRC - Internet Relay Chat, db-merger.c - * (C) Copyright 2005, Florian Schulze (Certus) - * - * Based on the original code of Anope, (C) 2003 Anope Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License (see it online - * at http://www.gnu.org/copyleft/gpl.html) as published by the Free - * Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This program tries to merge two standard anope-1.7.7+ database sets, - * that includes chanserv, nickserv, botserv and memoserv databases. - * - * - Certus - * February 11, 2005 - * - * - * 0.2 beta: - * Fixed some overflows in the ->flags and the ->status fields. Use db-fix - * to fix your broken nick dbs. - * - * - Certus - * August 04, 2005 - */ - #include <stdlib.h> #include <string.h> @@ -331,7 +300,7 @@ int main(int argc, char *argv[]) NickCore *nc, **nclast, *ncprev; int16 tmp16; int32 tmp32; - int i, j, c; + int i, j, c, mycount = 0; printf("Trying to merge nicks...\n"); @@ -356,6 +325,7 @@ int main(int argc, char *argv[]) ncprev = nc; READ(read_string(&nc->display, f)); + mycount++; READ(read_string(&nc->pass, f)); READ(read_string(&nc->email, f)); READ(read_string(&nc->greet, f)); @@ -391,6 +361,7 @@ int main(int argc, char *argv[]) } /* getc_db() */ *nclast = NULL; } /* for() loop */ + printf("mycount is %d\n", mycount); /* Nick aliases */ for (i = 0; i < 1024; i++) { @@ -630,13 +601,15 @@ int main(int argc, char *argv[]) NickCore *nc; char **access; Memo *memos; - int i, j; + int i, j, mycount = 0; /* Nick cores */ for (i = 0; i < 1024; i++) { for (nc = nclists[i]; nc; nc = nc->next) { SAFE(write_int8(1, f)); + mycount++; SAFE(write_string(nc->display, f)); + printf("Writing entry for nick %s\n", nc->display); SAFE(write_string(nc->pass, f)); SAFE(write_string(nc->email, f)); SAFE(write_string(nc->greet, f)); @@ -663,6 +636,7 @@ int main(int argc, char *argv[]) } /* for (nc) */ SAFE(write_int8(0, f)); } /* for (i) */ + printf("%d nicks merged\n", mycount); /* Nick aliases */ for (i = 0; i < 1024; i++) { diff --git a/version.log b/version.log index 640bf6bc3..80f031db6 100644 --- a/version.log +++ b/version.log @@ -9,14 +9,10 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="14" VERSION_EXTRA="" -VERSION_BUILD="1080" +VERSION_BUILD="1079" # $Log$ # -# BUILD : 1.7.14 (1080) -# BUGS : 491? -# NOTES : rewrote exception system due to a bug we couldn't track down. -# # BUILD : 1.7.14 (1079) # BUGS : 529 531 # NOTES : applied trystan's fix and fixed some readonly stuff |