diff options
author | Mystery Man <unknown@mandriva.org> | 2003-05-06 13:11:49 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2003-05-06 13:11:49 +0000 |
commit | 3f5d21d90abbd16f16ab69aec1e1a1853a93fd18 (patch) | |
tree | 3d9f5a32303a8d97b4b457949e64bb42b4850ea9 /mdk-stage1/insmod-modutils/obj/obj_gpl_license.c | |
parent | 327bd24f8e4291bd1882de1990dd7339f781a9cb (diff) | |
download | drakx-backup-do-not-use-R9_0-AMD64.tar drakx-backup-do-not-use-R9_0-AMD64.tar.gz drakx-backup-do-not-use-R9_0-AMD64.tar.bz2 drakx-backup-do-not-use-R9_0-AMD64.tar.xz drakx-backup-do-not-use-R9_0-AMD64.zip |
This commit was manufactured by cvs2svn to create tag 'R9_0-AMD64'.R9_0-AMD64
Diffstat (limited to 'mdk-stage1/insmod-modutils/obj/obj_gpl_license.c')
-rw-r--r-- | mdk-stage1/insmod-modutils/obj/obj_gpl_license.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/mdk-stage1/insmod-modutils/obj/obj_gpl_license.c b/mdk-stage1/insmod-modutils/obj/obj_gpl_license.c new file mode 100644 index 000000000..366b03e06 --- /dev/null +++ b/mdk-stage1/insmod-modutils/obj/obj_gpl_license.c @@ -0,0 +1,61 @@ +/* Return the type of license for a module. 0 for GPL, 1 for no license, 2 for + non-GPL. The license parameter is set to the license string or NULL. + + This file is part of the Linux modutils. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <string.h> +#include "obj.h" + +/* This list must match *exactly* the list of allowable licenses in + * linux/include/linux/module.h. Checking for leading "GPL" will not + * work, somebody will use "GPL sucks, this is proprietary". + */ +static const char *gpl_licenses[] = { + "GPL", + "GPL v2", + "GPL and additional rights", + "Dual BSD/GPL", + "Dual MPL/GPL", +}; + +int obj_gpl_license(struct obj_file *f, const char **license) +{ + struct obj_section *sec; + if ((sec = obj_find_section(f, ".modinfo"))) { + const char *value, *ptr, *endptr; + ptr = sec->contents; + endptr = ptr + sec->header.sh_size; + while (ptr < endptr) { + if ((value = strchr(ptr, '=')) && strncmp(ptr, "license", value-ptr) == 0) { + int i; + if (license) + *license = value+1; + for (i = 0; i < sizeof(gpl_licenses)/sizeof(gpl_licenses[0]); ++i) { + if (strcmp(value+1, gpl_licenses[i]) == 0) + return(0); + } + return(2); + } + if (strchr(ptr, '\0')) + ptr = strchr(ptr, '\0') + 1; + else + ptr = endptr; + } + } + return(1); +} |