Annotation of embedaddon/strongswan/src/libimcv/os_info/os_info.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2012-2014 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 "os_info.h"
                     17: 
                     18: ENUM(os_type_names, OS_TYPE_UNKNOWN, OS_TYPE_WINDOWS,
                     19:        "Unknown",
                     20:        "Debian",
                     21:        "Ubuntu",
                     22:        "Fedora",
                     23:        "Red Hat",
                     24:        "CentOS",
                     25:        "SUSE",
                     26:        "Gentoo",
                     27:        "Android",
                     28:        "Windows",
                     29: );
                     30: 
                     31: ENUM(os_fwd_status_names, OS_FWD_DISABLED, OS_FWD_UNKNOWN,
                     32:        "disabled",
                     33:        "enabled",
                     34:        "unknown"
                     35: );
                     36: 
                     37: ENUM(os_package_state_names, OS_PACKAGE_STATE_UPDATE, OS_PACKAGE_STATE_BLACKLIST,
                     38:        "",
                     39:        " [s]",
                     40:        " [b]"
                     41: );
                     42: 
                     43: /**
                     44:  * See header
                     45:  */
                     46: os_type_t os_type_from_name(chunk_t name)
                     47: {
                     48:        os_type_t type;
                     49:        char *name_str;
                     50: 
                     51:        for (type = OS_TYPE_DEBIAN; type < OS_TYPE_ROOF; type++)
                     52:        {
                     53:                /* name_str is a substring of name.ptr */
                     54:                name_str = enum_to_name(os_type_names, type);
                     55:                if (memeq(name.ptr, name_str, min(name.len, strlen(name_str))))
                     56:                {
                     57:                        return type;
                     58:                }
                     59:        }
                     60:        return OS_TYPE_UNKNOWN;
                     61: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>