summaryrefslogtreecommitdiff
path: root/src/sessions.c
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-09 21:01:05 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-09 21:01:05 +0000
commitd7d01bdc5c667a1fafd95241282b58e03b4caa5b (patch)
treef1482d8734da609923c6d8af6bc8fcb0fc187534 /src/sessions.c
parentd49b3a25fda5f597491e73640dd1e76babc240eb (diff)
Squashed commit: merge next (1.9.1) back to trunk.
SVN users, NOTE: THIS WILL NOT BUILD, NOR SHOULD YOU RUN IT YET. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1953 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/sessions.c')
-rw-r--r--src/sessions.c305
1 files changed, 0 insertions, 305 deletions
diff --git a/src/sessions.c b/src/sessions.c
index 0563156cf..94137b073 100644
--- a/src/sessions.c
+++ b/src/sessions.c
@@ -99,82 +99,6 @@ void get_exception_stats(long *nrec, long *memuse)
}
/*************************************************************************/
-/************************* Session List Display **************************/
-/*************************************************************************/
-
-/* Syntax: SESSION LIST threshold
- * Lists all sessions with atleast threshold clients.
- * The threshold value must be greater than 1. This is to prevent
- * accidental listing of the large number of single client sessions.
- *
- * Syntax: SESSION VIEW host
- * Displays detailed session information about the supplied host.
- */
-
-int do_session(User * u)
-{
- Session *session;
- Exception *exception;
- char *cmd = strtok(NULL, " ");
- char *param1 = strtok(NULL, " ");
- int mincount;
- int i;
-
- if (!LimitSessions) {
- notice_lang(s_OperServ, u, OPER_SESSION_DISABLED);
- return MOD_CONT;
- }
-
- if (!cmd)
- cmd = "";
-
- if (stricmp(cmd, "LIST") == 0) {
- if (!param1) {
- syntax_error(s_OperServ, u, "SESSION",
- OPER_SESSION_LIST_SYNTAX);
-
- } else if ((mincount = atoi(param1)) <= 1) {
- notice_lang(s_OperServ, u, OPER_SESSION_INVALID_THRESHOLD);
-
- } else {
- notice_lang(s_OperServ, u, OPER_SESSION_LIST_HEADER, mincount);
- notice_lang(s_OperServ, u, OPER_SESSION_LIST_COLHEAD);
- for (i = 0; i < 1024; i++) {
- for (session = sessionlist[i]; session;
- session = session->next) {
- if (session->count >= mincount)
- notice_lang(s_OperServ, u,
- OPER_SESSION_LIST_FORMAT,
- session->count, session->host);
- }
- }
- }
- } else if (stricmp(cmd, "VIEW") == 0) {
- if (!param1) {
- syntax_error(s_OperServ, u, "SESSION",
- OPER_SESSION_VIEW_SYNTAX);
-
- } else {
- session = findsession(param1);
- if (!session) {
- notice_lang(s_OperServ, u, OPER_SESSION_NOT_FOUND, param1);
- } else {
- exception = find_host_exception(param1);
-
- notice_lang(s_OperServ, u, OPER_SESSION_VIEW_FORMAT,
- param1, session->count,
- exception ? exception->
- limit : DefSessionLimit);
- }
- }
-
- } else {
- syntax_error(s_OperServ, u, "SESSION", OPER_SESSION_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
/********************* Internal Session Functions ************************/
/*************************************************************************/
@@ -615,232 +539,3 @@ static int exception_view_callback(User * u, int num, va_list args)
}
/*************************************************************************/
-
-/* Syntax: EXCEPTION ADD [+expiry] mask limit reason
- * Adds mask to the exception list with limit as the maximum session
- * limit and +expiry as an optional expiry time.
- *
- * Syntax: EXCEPTION DEL mask
- * Deletes the first exception that matches mask exactly.
- *
- * Syntax: EXCEPTION LIST [mask]
- * Lists all exceptions or those matching mask.
- *
- * 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)
-{
- char *cmd = strtok(NULL, " ");
- char *mask, *reason, *expiry, *limitstr;
- int limit, expires;
- int i;
- int x;
-
- if (!LimitSessions) {
- notice_lang(s_OperServ, u, OPER_EXCEPTION_DISABLED);
- return MOD_CONT;
- }
-
- if (!cmd)
- cmd = "";
-
- if (stricmp(cmd, "ADD") == 0) {
- if (nexceptions >= 32767) {
- notice_lang(s_OperServ, u, OPER_EXCEPTION_TOO_MANY);
- return MOD_CONT;
- }
-
- mask = strtok(NULL, " ");
- if (mask && *mask == '+') {
- expiry = mask;
- mask = strtok(NULL, " ");
- } else {
- expiry = NULL;
- }
- limitstr = strtok(NULL, " ");
- reason = strtok(NULL, "");
-
- if (!reason) {
- syntax_error(s_OperServ, u, "EXCEPTION",
- OPER_EXCEPTION_ADD_SYNTAX);
- return MOD_CONT;
- }
-
- expires = expiry ? dotime(expiry) : ExceptionExpiry;
- if (expires < 0) {
- notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
- return MOD_CONT;
- } else if (expires > 0) {
- expires += time(NULL);
- }
-
- limit = (limitstr && isdigit(*limitstr)) ? atoi(limitstr) : -1;
-
- if (limit < 0 || limit > MaxSessionLimit) {
- notice_lang(s_OperServ, u, OPER_EXCEPTION_INVALID_LIMIT,
- MaxSessionLimit);
- return MOD_CONT;
-
- } else {
- if (strchr(mask, '!') || strchr(mask, '@')) {
- notice_lang(s_OperServ, u,
- OPER_EXCEPTION_INVALID_HOSTMASK);
- return MOD_CONT;
- }
-
- x = exception_add(u, mask, limit, reason, u->nick, expires);
-
- 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) {
- mask = strtok(NULL, " ");
-
- if (!mask) {
- syntax_error(s_OperServ, u, "EXCEPTION",
- OPER_EXCEPTION_DEL_SYNTAX);
- return MOD_CONT;
- }
-
- 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);
- }
-
- /* 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 = static_cast<Exception *>(smalloc(sizeof(Exception)));
- 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;
- expire_exceptions();
- mask = strtok(NULL, " ");
- 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;
- expire_exceptions();
- mask = strtok(NULL, " ");
- 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);
-
- } else {
- syntax_error(s_OperServ, u, "EXCEPTION", OPER_EXCEPTION_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/