Annotation of embedaddon/strongswan/src/libimcv/imv/imv_lang_string.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2012 Andreas Steffen
! 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 "imv_lang_string.h"
! 17:
! 18: #include <utils/debug.h>
! 19:
! 20: /**
! 21: * Described in header.
! 22: */
! 23: char* imv_lang_string_select_lang(enumerator_t *language_enumerator,
! 24: char* languages[], int lang_count)
! 25: {
! 26: bool match = FALSE;
! 27: char *lang;
! 28: int i, i_chosen = 0;
! 29:
! 30: while (language_enumerator->enumerate(language_enumerator, &lang))
! 31: {
! 32: for (i = 0; i < lang_count; i++)
! 33: {
! 34: if (streq(lang, languages[i]))
! 35: {
! 36: match = TRUE;
! 37: i_chosen = i;
! 38: break;
! 39: }
! 40: }
! 41: if (match)
! 42: {
! 43: break;
! 44: }
! 45: }
! 46: return languages[i_chosen];
! 47: }
! 48:
! 49: /**
! 50: * Described in header.
! 51: */
! 52: char* imv_lang_string_select_string(imv_lang_string_t lang_string[], char *lang)
! 53: {
! 54: char *string;
! 55: int i = 0;
! 56:
! 57: if (!lang_string)
! 58: {
! 59: return NULL;
! 60: }
! 61:
! 62: string = lang_string[0].string;
! 63: while (lang_string[i].lang)
! 64: {
! 65: if (streq(lang, lang_string[i].lang))
! 66: {
! 67: string = lang_string[i].string;
! 68: break;
! 69: }
! 70: i++;
! 71: }
! 72: return string;
! 73: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>