Skip to content
Snippets Groups Projects
Select Git revision
  • bcrypt
  • master default protected
  • hpke
  • ppc-chacha-4core
  • delete-internal-name-mangling
  • master-updates
  • ppc-gcm
  • ppc-chacha-2core
  • refactor-ecc-mod
  • ppc-chacha-core
  • use-mpn_cnd-functions
  • optimize-ecc-invert
  • default-m4-quote-char
  • power-asm-wip
  • test-fat
  • chacha-3core-neon
  • x86_64-salsa20-2core
  • salsa20-2core-neon
  • arm-salsa20-chacha-vsra
  • test-shlib-dir
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
40 results

aes-set-key-internal.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    send-async.c 7.53 KiB
    /*
     * $Id: send-async.c,v 0.17 1996/07/28 12:46:31 ceder Exp $
     * Copyright (C) 1991, 1993, 1994, 1995  Lysator Academic Computer Association.
     *
     * This file is part of the LysKOM server.
     * 
     * LysKOM is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by 
     * the Free Software Foundation; either version 1, or (at your option) 
     * any later version.
     * 
     * LysKOM 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.
     * 
     * You should have received a copy of the GNU General Public License
     * along with LysKOM; see the file COPYING.  If not, write to
     * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
     * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
     * MA 02139, USA.
     *
     * Please mail bug reports to bug-lyskom@lysator.liu.se. 
     */
    /*
     * send-async.c -- Send messages about events to all connected clients.
     *
     * Written by Per Cederqvist 1990-07-22--23
     */
    
    static char *rcsid = "$Id: send-async.c,v 0.17 1996/07/28 12:46:31 ceder Exp $";
    #include "rcs.h"
    USE(rcsid);
    
    #include <stdio.h>
    #include <setjmp.h>
    #ifdef HAVE_STDARG_H
    #  include <stdarg.h>
    #endif
    #include <time.h>
    #include <sys/types.h>
    
    #include "misc-types.h"
    #include "s-string.h"
    #include "kom-types.h"
    #include "com.h"
    #include "async.h"
    #include "connections.h"
    #include "internal-connections.h"
    #include "async.h"
    #include "send-async.h"
    #include "prot-a-send-async.h"
    #include "lyskomd.h"
    #include "log.h"
    #include "param.h"
    #include "ldifftime.h"
    #include "manipulate.h"
    
    void
    async_new_text(struct connection *cptr,
    	       Text_no    	  text_no, 
    	       Text_stat         *text_s)
    {
        if (!param.send_async_messages)
    	return;
    
        switch(cptr->protocol)
        {
        case 0:
    	break;
        case 'A':
    	prot_a_async_new_text(cptr, text_no, text_s);
    	break;
        default:
    	restart_kom("async_new_text(): bad protocol.\n");
    	break;
        }
    }
    
        
        
    	    
    void
    async_i_am_on(Who_info info)
    {
        Connection *cptr;
        Session_no i = 0;
    
        if (!param.send_async_messages)
    	return;
    
        while ( (i = traverse_connections(i)) != 0 )
        {
    	cptr = get_conn_by_number(i);
    
    	switch(cptr->protocol)
    	{
    	case 0:			/* Not yet logged on. */
    	    break;
    	case 'A':
    	    prot_a_async_i_am_on(cptr, info);
    	    break;
    	default:
    	    restart_kom("async_i_am_on(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    void
    async_logout(Pers_no pers_no, 
    	     Session_no session_no)
    {
        Connection *cptr;
        Session_no i = 0;
    
        if (!param.send_async_messages)
    	return;
    
        while ( (i = traverse_connections(i)) != 0)
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_logout(): cptr == NULL\n");
    	    return;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    prot_a_async_logout(cptr, pers_no, session_no);
    	    break;
    	default:
    	    restart_kom("async_logout(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    
    
    void
    async_new_name(Conf_no 	     conf_no,
    	       const String  old_name,
    	       const String  new_name)
    {
        Connection *cptr;
        Session_no i = 0;
    
        if (!param.send_async_messages)
    	return;
    
        while ( (i = traverse_connections(i)) != 0)
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_new_name(): cptr == NULL\n");
    	    return;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    /* Should check that cptr has enough privileges to know
    	       anything about the conference. +++ */
                if (fast_access_perm(conf_no,
                                     cptr->pers_no,
                                     cptr->person) > none)
                {
                    prot_a_async_new_name(cptr, conf_no, old_name, new_name);
                }
    	    break;
    		
    	default:
    	    restart_kom("async_new_name(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    
    
    
    #if 0    
    conf_deleted
    conf_created
    #endif
    
    void
    async_sync_db(void)
    {
        Connection *cptr;
        Session_no i = 0;
    
        if (!param.send_async_messages)
    	return;
    
        while ( (i = traverse_connections(i)) != 0 )
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_sync_db(): cptr == NULL\n");
    	    return;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    prot_a_async_sync_db(cptr);
    	    break;
    	default:
    	    restart_kom("async_sync_db(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    
    extern void
    async_forced_leave_conf (struct connection *cptr,
    			 Conf_no 	   conf_no)
    {
        if (!param.send_async_messages)
    	return;
    
        switch(cptr->protocol)
        {
        case 0:
    	break;
        case 'A':
    	prot_a_async_forced_leave_conf(cptr, conf_no);
    	break;
        default:
    	restart_kom("async_forced_leave_conf(): bad protocol.\n");
    	break;
        }
    }
    
    void
    async_login(Pers_no	pers_no,
    	    int		client_no)
    {
        Connection *cptr;
        Session_no i = 0;
    
        if (!param.send_async_messages)
    	return;
    
        while ( (i = traverse_connections(i)) != 0)
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_login(): cptr == NULL\n");
    	    return;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    prot_a_async_login(cptr, pers_no, client_no);
    	    break;
    		
    	default:
    	    restart_kom("async_login(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    void
    async_rejected_connection(void)
    {
        Connection *cptr;
        Session_no i = 0;
        static time_t last_time = 0;
        time_t curr_time;
    
        if (!param.send_async_messages)
    	return;
    
        time(&curr_time);
        if (last_time != 0 && ldifftime(curr_time, last_time) < 60)
    	 return;
    
        last_time = curr_time;
    	
        while ( (i = traverse_connections(i)) != 0)
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_rejected_connections(): cptr == NULL\n");
    	    return;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    prot_a_async_rejected_connection(cptr);
    	    break;
    		
    	default:
    	    restart_kom("async_rejected_connection(): bad protocol.\n");
    	    break;
    	}
        }
    }
    
    
    /*
     * Returns failure if no message was sent.
     */
    Success
    async_send_message(Pers_no recipient,
    		   Pers_no sender,
    		   String  message,
                       char    force_message)
    {
        return async_send_group_message(recipient,
                                        recipient,
                                        sender,
                                        message,
                                        force_message);
    }
    
    Success
    async_send_group_message(Pers_no recipient,
    			 Conf_no group_recipient,
    			 Pers_no sender,
    			 String  message,
                             char    force_message)
    {
        Connection *cptr;
        Session_no i = 0;
        Success retval = FAILURE;
        Bool tmp = FALSE;
    
        if (!param.send_async_messages)
    	return FAILURE;
    
        while ( (i = traverse_connections(i)) != 0)
        {
    	cptr = get_conn_by_number(i);
    
    	if ( cptr == NULL )
    	{
    	    log("async_send_message(): cptr == NULL\n");
    	    return FAILURE;
    	}
    
    	switch(cptr->protocol)
    	{
    	case 0:
    	    break;
    	case 'A':
    	    if ( recipient == 0 ||
    		(recipient == cptr->pers_no && recipient != 0 ))
    	    {
                    if (force_message)
                    {
                        tmp = cptr->want_async[ay_send_message];
                        cptr->want_async[ay_send_message] = TRUE;
                    }
    		prot_a_async_send_message(cptr, group_recipient,
    					  sender, message);
                    if (force_message)
                        cptr->want_async[ay_send_message] = tmp;
    		retval = OK;
    	    }
    	    break;
    		
    	default:
    	    restart_kom("async_send_message(): bad protocol.\n");
    	    break;
    	}
        }
        
        return retval;
    }