Annotation of embedaddon/strongswan/src/libstrongswan/resolver/resolver_manager.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2011-2012 Reto Guadagnini
! 3: * HSR Hochschule fuer Technik Rapperswil
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: #include "resolver_manager.h"
! 17:
! 18: #include <utils/debug.h>
! 19:
! 20: typedef struct private_resolver_manager_t private_resolver_manager_t;
! 21:
! 22: /**
! 23: * private data of resolver_manager
! 24: */
! 25: struct private_resolver_manager_t {
! 26:
! 27: /**
! 28: * public functions
! 29: */
! 30: resolver_manager_t public;
! 31:
! 32: /**
! 33: * constructor function to create resolver instances
! 34: */
! 35: resolver_constructor_t constructor;
! 36: };
! 37:
! 38: METHOD(resolver_manager_t, add_resolver, void,
! 39: private_resolver_manager_t *this, resolver_constructor_t constructor)
! 40: {
! 41: if (!this->constructor)
! 42: {
! 43: this->constructor = constructor;
! 44: }
! 45: }
! 46:
! 47: METHOD(resolver_manager_t, remove_resolver, void,
! 48: private_resolver_manager_t *this, resolver_constructor_t constructor)
! 49: {
! 50: if (this->constructor == constructor)
! 51: {
! 52: this->constructor = NULL;
! 53: }
! 54: }
! 55:
! 56: METHOD(resolver_manager_t, create, resolver_t*,
! 57: private_resolver_manager_t *this)
! 58: {
! 59: if (this->constructor)
! 60: {
! 61: return this->constructor();
! 62: }
! 63: return NULL;
! 64: }
! 65:
! 66: METHOD(resolver_manager_t, destroy, void,
! 67: private_resolver_manager_t *this)
! 68: {
! 69: free(this);
! 70: }
! 71:
! 72: /*
! 73: * See header
! 74: */
! 75: resolver_manager_t *resolver_manager_create()
! 76: {
! 77: private_resolver_manager_t *this;
! 78:
! 79: INIT(this,
! 80: .public = {
! 81: .add_resolver = _add_resolver,
! 82: .remove_resolver = _remove_resolver,
! 83: .create = _create,
! 84: .destroy = _destroy,
! 85: },
! 86: );
! 87:
! 88: return &this->public;
! 89: }
! 90:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>