diff options
author | Tom Yu <tlyu@mit.edu> | 2008-10-15 21:58:43 +0000 |
---|---|---|
committer | Tom Yu <tlyu@mit.edu> | 2008-10-15 21:58:43 +0000 |
commit | a898a72410a38b03ff7c7691ceeea973e3eec6ca (patch) | |
tree | fdd601d15bb96904df7b684048381bb3b9d0e1d3 /src/lib/gssapi/generic/util_errmap.c | |
parent | 07292e360eb8cad0151ed76edee11a9ce8ca925e (diff) | |
download | krb5-a898a72410a38b03ff7c7691ceeea973e3eec6ca.tar.gz krb5-a898a72410a38b03ff7c7691ceeea973e3eec6ca.tar.xz krb5-a898a72410a38b03ff7c7691ceeea973e3eec6ca.zip |
Untabify. Normalize whitespace. Reindent. Fix some of the most
egregious formatting quirks. Add emacs mode settings to flag
untabified source files.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20876 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/gssapi/generic/util_errmap.c')
-rw-r--r-- | src/lib/gssapi/generic/util_errmap.c | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/src/lib/gssapi/generic/util_errmap.c b/src/lib/gssapi/generic/util_errmap.c index 9e2f7e9b3..2634e667b 100644 --- a/src/lib/gssapi/generic/util_errmap.c +++ b/src/lib/gssapi/generic/util_errmap.c @@ -1,3 +1,4 @@ +/* -*- mode: c; indent-tabs-mode: nil -*- */ /* * Copyright 2007, 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. @@ -6,7 +7,7 @@ * require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. - * + * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright @@ -20,7 +21,7 @@ * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. - * + * */ #include "gssapiP_generic.h" @@ -45,26 +46,26 @@ static inline int cmp_OM_uint32(OM_uint32 m1, OM_uint32 m2) { if (m1 < m2) - return -1; + return -1; else if (m1 > m2) - return 1; + return 1; else - return 0; + return 0; } static inline int mecherror_cmp(struct mecherror m1, struct mecherror m2) { if (m1.code < m2.code) - return -1; + return -1; if (m1.code > m2.code) - return 1; + return 1; if (m1.mech.length < m2.mech.length) - return -1; + return -1; if (m1.mech.length > m2.mech.length) - return 1; + return 1; if (m1.mech.length == 0) - return 0; + return 0; return memcmp(m1.mech.elements, m2.mech.elements, m1.mech.length); } @@ -80,10 +81,10 @@ mecherror_copy(struct mecherror *dest, struct mecherror src) *dest = src; dest->mech.elements = malloc(src.mech.length); if (dest->mech.elements == NULL) { - if (src.mech.length) - return ENOMEM; - else - return 0; + if (src.mech.length) + return ENOMEM; + else + return 0; } memcpy(dest->mech.elements, src.mech.elements, src.mech.length); return 0; @@ -95,40 +96,40 @@ mecherror_print(struct mecherror value, FILE *f) OM_uint32 minor; gss_buffer_desc str; static const struct { - const char *oidstr, *name; + const char *oidstr, *name; } mechnames[] = { - { "{ 1 2 840 113554 1 2 2 }", "krb5-new" }, - { "{ 1 3 5 1 5 2 }", "krb5-old" }, - { "{ 1 2 840 48018 1 2 2 }", "krb5-microsoft" }, - { "{ 1 3 6 1 5 5 2 }", "spnego" }, + { "{ 1 2 840 113554 1 2 2 }", "krb5-new" }, + { "{ 1 3 5 1 5 2 }", "krb5-old" }, + { "{ 1 2 840 48018 1 2 2 }", "krb5-microsoft" }, + { "{ 1 3 6 1 5 5 2 }", "spnego" }, }; unsigned int i; fprintf(f, "%lu@", (unsigned long) value.code); if (value.mech.length == 0) { - fprintf(f, "(com_err)"); - return; + fprintf(f, "(com_err)"); + return; } fprintf(f, "%p=", value.mech.elements); if (generic_gss_oid_to_str(&minor, &value.mech, &str)) { - fprintf(f, "(error in conversion)"); - return; + fprintf(f, "(error in conversion)"); + return; } /* Note: generic_gss_oid_to_str returns a null-terminated string. */ for (i = 0; i < sizeof(mechnames)/sizeof(mechnames[0]); i++) { - if (!strcmp(str.value, mechnames[i].oidstr) && mechnames[i].name != 0) { - fprintf(f, "%s", mechnames[i].name); - break; - } + if (!strcmp(str.value, mechnames[i].oidstr) && mechnames[i].name != 0) { + fprintf(f, "%s", mechnames[i].name); + break; + } } if (i == sizeof(mechnames)/sizeof(mechnames[0])) - fprintf(f, "%s", (char *) str.value); + fprintf(f, "%s", (char *) str.value); generic_gss_release_buffer(&minor, &str); } #include "errmap.h" -#include "krb5.h" /* for KRB5KRB_AP_WRONG_PRINC */ +#include "krb5.h" /* for KRB5KRB_AP_WRONG_PRINC */ static mecherrmap m; static k5_mutex_t mutex = K5_MUTEX_PARTIAL_INITIALIZER; @@ -140,11 +141,11 @@ int gssint_mecherrmap_init(void) err = mecherrmap_init(&m); if (err) - return err; + return err; err = k5_mutex_finish_init(&mutex); if (err) { - mecherrmap_destroy(&m); - return err; + mecherrmap_destroy(&m); + return err; } return 0; @@ -155,7 +156,7 @@ int gssint_mecherrmap_init(void) static int free_one(OM_uint32 i, struct mecherror value, void *p) { if (value.mech.length && value.mech.elements) - free(value.mech.elements); + free(value.mech.elements); return 0; } @@ -178,7 +179,7 @@ OM_uint32 gssint_mecherrmap_map(OM_uint32 minor, const gss_OID_desc * oid) FILE *f; f = fopen("/dev/pts/9", "w+"); if (f == NULL) - f = stderr; + f = stderr; #endif me.code = minor; @@ -186,51 +187,51 @@ OM_uint32 gssint_mecherrmap_map(OM_uint32 minor, const gss_OID_desc * oid) err = k5_mutex_lock(&mutex); if (err) { #ifdef DEBUG - if (f != stderr) fclose(f); + if (f != stderr) fclose(f); #endif - return 0; + return 0; } /* Is this status+oid already mapped? */ p = mecherrmap_findright(&m, me); if (p != NULL) { - k5_mutex_unlock(&mutex); + k5_mutex_unlock(&mutex); #ifdef DEBUG - fprintf(f, "%s: found ", __func__); - mecherror_print(me, f); - fprintf(f, " in map as %lu\n", (unsigned long) *p); - if (f != stderr) fclose(f); + fprintf(f, "%s: found ", __func__); + mecherror_print(me, f); + fprintf(f, " in map as %lu\n", (unsigned long) *p); + if (f != stderr) fclose(f); #endif - return *p; + return *p; } /* Is this status code already mapped to something else mech-specific? */ mep = mecherrmap_findleft(&m, minor); if (mep == NULL) { - /* Map it to itself plus this mech-oid. */ - new_status = minor; + /* Map it to itself plus this mech-oid. */ + new_status = minor; } else { - /* Already assigned. Pick a fake new value and map it. */ - /* There's a theoretical infinite loop risk here, if we fill - in 2**32 values. Also, returning 0 has a special - meaning. */ - do { - next_fake++; - new_status = next_fake; - if (new_status == 0) - /* ??? */; - } while (mecherrmap_findleft(&m, new_status) != NULL); + /* Already assigned. Pick a fake new value and map it. */ + /* There's a theoretical infinite loop risk here, if we fill + in 2**32 values. Also, returning 0 has a special + meaning. */ + do { + next_fake++; + new_status = next_fake; + if (new_status == 0) + /* ??? */; + } while (mecherrmap_findleft(&m, new_status) != NULL); } err = mecherror_copy(&me_copy, me); if (err) { - k5_mutex_unlock(&mutex); - return err; + k5_mutex_unlock(&mutex); + return err; } err = mecherrmap_add(&m, new_status, me_copy); k5_mutex_unlock(&mutex); if (err) { - if (me_copy.mech.length) - free(me_copy.mech.elements); + if (me_copy.mech.length) + free(me_copy.mech.elements); } #ifdef DEBUG fprintf(f, "%s: mapping ", __func__); @@ -241,9 +242,9 @@ OM_uint32 gssint_mecherrmap_map(OM_uint32 minor, const gss_OID_desc * oid) if (f != stderr) fclose(f); #endif if (err) - return 0; + return 0; else - return new_status; + return new_status; } static gss_OID_desc no_oid = { 0, 0 }; @@ -253,21 +254,21 @@ OM_uint32 gssint_mecherrmap_map_errcode(OM_uint32 errcode) } int gssint_mecherrmap_get(OM_uint32 minor, gss_OID mech_oid, - OM_uint32 *mech_minor) + OM_uint32 *mech_minor) { const struct mecherror *p; int err; if (minor == 0) { - return EINVAL; + return EINVAL; } err = k5_mutex_lock(&mutex); if (err) - return err; + return err; p = mecherrmap_findleft(&m, minor); k5_mutex_unlock(&mutex); if (!p) { - return EINVAL; + return EINVAL; } *mech_oid = p->mech; *mech_minor = p->code; |