diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2004-12-15 13:26:39 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2004-12-15 13:26:39 +0000 |
commit | 70df10844ac7f46e43a20040b7735fbae795dc4b (patch) | |
tree | 162b0b69f284326a7d9334a294c93bae86417665 | |
parent | 06b00a25f3753dcbc6ff7fe9c3a774b1620d8b7e (diff) | |
download | drakx-70df10844ac7f46e43a20040b7735fbae795dc4b.tar drakx-70df10844ac7f46e43a20040b7735fbae795dc4b.tar.gz drakx-70df10844ac7f46e43a20040b7735fbae795dc4b.tar.bz2 drakx-70df10844ac7f46e43a20040b7735fbae795dc4b.tar.xz drakx-70df10844ac7f46e43a20040b7735fbae795dc4b.zip |
add missing file from older merge from modutils 2.4.26
-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); +} |