init.c

Go to the documentation of this file.
00001 /* init.c --- Entry point for libgsasl.
00002  * Copyright (C) 2002, 2003, 2004, 2005  Simon Josefsson
00003  *
00004  * This file is part of GNU SASL Library.
00005  *
00006  * GNU SASL Library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation; either version 2.1 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * GNU SASL Library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License License along with GNU SASL Library; if not, write to the
00018  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "internal.h"
00024 
00025 /* Get gc_init. */
00026 #include <gc.h>
00027 
00028 /* Get mechanism headers. */
00029 #include "cram-md5/cram-md5.h"
00030 #include "external/external.h"
00031 #include "gssapi/x-gssapi.h"
00032 #include "anonymous/anonymous.h"
00033 #include "plain/plain.h"
00034 #include "securid/securid.h"
00035 #include "digest-md5/digest-md5.h"
00036 
00037 #include "login/login.h"
00038 #include "ntlm/x-ntlm.h"
00039 #include "kerberos_v5/kerberos_v5.h"
00040 
00047 const char *GSASL_VALID_MECHANISM_CHARACTERS =
00048   "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
00049 
00050 static int
00051 register_builtin_mechs (Gsasl * ctx)
00052 {
00053   int rc = GSASL_OK;
00054 
00055 #ifdef USE_ANONYMOUS
00056   rc = gsasl_register (ctx, &gsasl_anonymous_mechanism);
00057   if (rc != GSASL_OK)
00058     return rc;
00059 #endif /* USE_ANONYMOUS */
00060 
00061 #ifdef USE_EXTERNAL
00062   rc = gsasl_register (ctx, &gsasl_external_mechanism);
00063   if (rc != GSASL_OK)
00064     return rc;
00065 #endif /* USE_EXTERNAL */
00066 
00067 #ifdef USE_LOGIN
00068   rc = gsasl_register (ctx, &gsasl_login_mechanism);
00069   if (rc != GSASL_OK)
00070     return rc;
00071 #endif /* USE_LOGIN */
00072 
00073 #ifdef USE_PLAIN
00074   rc = gsasl_register (ctx, &gsasl_plain_mechanism);
00075   if (rc != GSASL_OK)
00076     return rc;
00077 #endif /* USE_PLAIN */
00078 
00079 #ifdef USE_SECURID
00080   rc = gsasl_register (ctx, &gsasl_securid_mechanism);
00081   if (rc != GSASL_OK)
00082     return rc;
00083 #endif /* USE_SECURID */
00084 
00085 #ifdef USE_NTLM
00086   rc = gsasl_register (ctx, &gsasl_ntlm_mechanism);
00087   if (rc != GSASL_OK)
00088     return rc;
00089 #endif /* USE_NTLM */
00090 
00091 #ifdef USE_DIGEST_MD5
00092   rc = gsasl_register (ctx, &gsasl_digest_md5_mechanism);
00093   if (rc != GSASL_OK)
00094     return rc;
00095 #endif /* USE_DIGEST_MD5 */
00096 
00097 #ifdef USE_CRAM_MD5
00098   rc = gsasl_register (ctx, &gsasl_cram_md5_mechanism);
00099   if (rc != GSASL_OK)
00100     return rc;
00101 #endif /* USE_CRAM_MD5 */
00102 
00103 #ifdef USE_GSSAPI
00104   rc = gsasl_register (ctx, &gsasl_gssapi_mechanism);
00105   if (rc != GSASL_OK)
00106     return rc;
00107 #endif /* USE_GSSAPI */
00108 
00109   return GSASL_OK;
00110 }
00111 
00123 int
00124 gsasl_init (Gsasl ** ctx)
00125 {
00126   int rc;
00127 
00128   if (gc_init () != GC_OK)
00129     return GSASL_CRYPTO_ERROR;
00130 
00131   *ctx = (Gsasl *) calloc (1, sizeof (**ctx));
00132   if (*ctx == NULL)
00133     return GSASL_MALLOC_ERROR;
00134 
00135   rc = register_builtin_mechs (*ctx);
00136   if (rc != GSASL_OK)
00137     {
00138       gsasl_done (*ctx);
00139       return rc;
00140     }
00141 
00142   return GSASL_OK;
00143 }

Generated on Tue Aug 22 12:06:06 2006 for gsasl by  doxygen 1.4.7