loudmouth/src/lm-ssl-base.c
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
       
     2 /*
       
     3  * Copyright (C) 2003-2006 Imendio AB
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public License as
       
     7  * published by the Free Software Foundation; either version 2 of the
       
     8  * License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this program; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 #include "lm-ssl-base.h"
       
    22 #include "lm-ssl-internals.h"
       
    23 
       
    24 void
       
    25 _lm_ssl_base_init (LmSSLBase      *base, 
       
    26 		   const gchar    *expected_fingerprint,
       
    27 		   LmSSLFunction   ssl_function,
       
    28 		   gpointer        user_data,
       
    29 		   GDestroyNotify  notify)
       
    30 {
       
    31 	base->ref_count      = 1;
       
    32 	base->func           = ssl_function;
       
    33 	base->func_data      = user_data;
       
    34 	base->data_notify    = notify;
       
    35 	base->fingerprint[0] = '\0';
       
    36 	
       
    37 	if (expected_fingerprint) {
       
    38 		base->expected_fingerprint = g_strdup (expected_fingerprint);
       
    39 	} else {
       
    40 		base->expected_fingerprint = NULL;
       
    41 	}
       
    42 
       
    43 	if (!base->func) {
       
    44 		/* If user didn't provide an SSL func the default will be used
       
    45 		 * this function will always tell the connection to continue.
       
    46 		 */
       
    47 		base->func = _lm_ssl_func_always_continue;
       
    48 	}
       
    49 }
       
    50 
       
    51 void
       
    52 _lm_ssl_base_free_fields (LmSSLBase *base)
       
    53 {
       
    54 	g_free (base->expected_fingerprint);
       
    55 }
       
    56