diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 02bd8064f44d7c8994a8a542a1ba2be792c9c318..50976649aa9bbe82fdd792c8a2e7e010c3901a1b 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -102,7 +102,8 @@ libcommon_la_SOURCES = \ stepd_api.c stepd_api.h \ write_labelled_message.c \ write_labelled_message.h \ - proc_args.c proc_args.h + proc_args.c proc_args.h \ + slurm_strcasestr.c slurm_strcasestr.h EXTRA_libcommon_la_SOURCES = \ $(extra_unsetenv_src) diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 7d9b9f81b744e6da84cba09fdf9756ae37a55149..32ae8009d51b9746812bb8fc4710319892447f6f 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -116,7 +116,7 @@ am__libcommon_la_SOURCES_DIST = assoc_mgr.c assoc_mgr.h \ parse_time.h job_options.c job_options.h global_defaults.c \ timers.c timers.h slurm_xlator.h stepd_api.c stepd_api.h \ write_labelled_message.c write_labelled_message.h proc_args.c \ - proc_args.h + proc_args.h slurm_strcasestr.c slurm_strcasestr.h @HAVE_UNSETENV_FALSE@am__objects_1 = unsetenv.lo am_libcommon_la_OBJECTS = assoc_mgr.lo basil_resv_conf.lo xmalloc.lo \ xassert.lo xstring.lo xsignal.lo forward.lo strlcpy.lo list.lo \ @@ -134,7 +134,7 @@ am_libcommon_la_OBJECTS = assoc_mgr.lo basil_resv_conf.lo xmalloc.lo \ slurm_resource_info.lo hostlist.lo slurm_step_layout.lo \ checkpoint.lo select_job_res.lo parse_time.lo job_options.lo \ global_defaults.lo timers.lo stepd_api.lo \ - write_labelled_message.lo proc_args.lo + write_labelled_message.lo proc_args.lo slurm_strcasestr.lo am__EXTRA_libcommon_la_SOURCES_DIST = unsetenv.c unsetenv.h libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) libcommon_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -442,7 +442,8 @@ libcommon_la_SOURCES = \ stepd_api.c stepd_api.h \ write_labelled_message.c \ write_labelled_message.h \ - proc_args.c proc_args.h + proc_args.c proc_args.h \ + slurm_strcasestr.c slurm_strcasestr.h EXTRA_libcommon_la_SOURCES = \ $(extra_unsetenv_src) @@ -591,6 +592,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_rlimits_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_selecttype_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_step_layout.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurm_strcasestr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurmdbd_defs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stepd_api.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Plo@am__quote@ diff --git a/src/common/parse_spec.c b/src/common/parse_spec.c index e559d39f7bbdd0873b063dc3a6414d62af6feedb..01c1dbbae6013993b75466f46d9024de07576ab6 100644 --- a/src/common/parse_spec.c +++ b/src/common/parse_spec.c @@ -56,6 +56,7 @@ #include "src/common/parse_spec.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" +#include "src/common/slurm_strcasestr.h" #define BUFFER_SIZE 1024 @@ -140,7 +141,7 @@ _load_float (float *destination, char *keyword, char *in_line) char *str_ptr1, *str_ptr2, *str_ptr3; int i, str_len1, str_len2; - str_ptr1 = (char *) strcasestr (in_line, keyword); + str_ptr1 = (char *) slurm_strcasestr (in_line, keyword); if (str_ptr1 != NULL) { str_len1 = strlen (keyword); strcpy (scratch, str_ptr1 + str_len1); @@ -178,7 +179,7 @@ _load_integer (int *destination, char *keyword, char *in_line) char *str_ptr1, *str_ptr2, *str_ptr3; int i, str_len1, str_len2; - str_ptr1 = (char *) strcasestr (in_line, keyword); + str_ptr1 = (char *) slurm_strcasestr (in_line, keyword); if (str_ptr1 != NULL) { str_len1 = strlen (keyword); strcpy (scratch, str_ptr1 + str_len1); @@ -235,7 +236,7 @@ _load_long (long *destination, char *keyword, char *in_line) char *str_ptr1, *str_ptr2, *str_ptr3; int i, str_len1, str_len2; - str_ptr1 = (char *) strcasestr (in_line, keyword); + str_ptr1 = (char *) slurm_strcasestr (in_line, keyword); if (str_ptr1 != NULL) { str_len1 = strlen (keyword); strcpy (scratch, str_ptr1 + str_len1); @@ -293,7 +294,7 @@ load_string (char **destination, char *keyword, char *in_line) char *str_ptr1, *str_ptr2, *str_ptr3; int i, str_len1, str_len2; - str_ptr1 = (char *) strcasestr (in_line, keyword); + str_ptr1 = (char *) slurm_strcasestr (in_line, keyword); if (str_ptr1 != NULL) { int quoted = 0; str_len1 = strlen (keyword); diff --git a/src/common/slurm_accounting_storage.c b/src/common/slurm_accounting_storage.c index 38b92860b7f3e5af1cf6a70632eda05b5e0d064d..81e6ec1792baff9f0a4b1a779b757334875acc6e 100644 --- a/src/common/slurm_accounting_storage.c +++ b/src/common/slurm_accounting_storage.c @@ -58,6 +58,7 @@ #include "src/common/xstring.h" #include "src/slurmctld/slurmctld.h" #include "src/sacctmgr/sacctmgr.h" +#include "src/common/slurm_strcasestr.h" /* * Local data @@ -7277,16 +7278,16 @@ extern uint16_t str_2_classification(char *class) if(!class) return type; - if(strcasestr(class, "capac")) + if(slurm_strcasestr(class, "capac")) type = ACCT_CLASS_CAPACITY; - else if(strcasestr(class, "capab")) + else if(slurm_strcasestr(class, "capab")) type = ACCT_CLASS_CAPABILITY; - else if(strcasestr(class, "capap")) + else if(slurm_strcasestr(class, "capap")) type = ACCT_CLASS_CAPAPACITY; - if(strcasestr(class, "*")) + if(slurm_strcasestr(class, "*")) type |= ACCT_CLASSIFIED_FLAG; - else if(strcasestr(class, "class")) + else if(slurm_strcasestr(class, "class")) type |= ACCT_CLASSIFIED_FLAG; return type; diff --git a/src/common/slurm_strcasestr.c b/src/common/slurm_strcasestr.c new file mode 100644 index 0000000000000000000000000000000000000000..944b45e6cfe7f5ca9d8e2fa7fc7526b98206c152 --- /dev/null +++ b/src/common/slurm_strcasestr.c @@ -0,0 +1,65 @@ +/*****************************************************************************\ + * slurm_strcasestr.h - case insensitve version of strstr() + ***************************************************************************** + * Copyright (C) 2009 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by David Bremer <dbremer@llnl.gov> + * CODE-OCEC-09-009. All rights reserved. + * + * This file is part of SLURM, a resource management program. + * For details, see <https://computing.llnl.gov/linux/slurm/>. + * Please also read the included file: DISCLAIMER. + * + * SLURM 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. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * SLURM 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 SLURM; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#include "slurm_strcasestr.h" +#include <ctype.h> + +/* case insensitve version of strstr() */ +char * +slurm_strcasestr(char *haystack, char *needle) +{ + int hay_inx, hay_size = strlen(haystack); + int need_inx, need_size = strlen(needle); + char *hay_ptr = haystack; + + for (hay_inx=0; hay_inx<hay_size; hay_inx++) { + for (need_inx=0; need_inx<need_size; need_inx++) { + if (tolower((int) hay_ptr[need_inx]) != + tolower((int) needle [need_inx])) + break; /* mis-match */ + } + + if (need_inx == need_size) /* it matched */ + return hay_ptr; + else /* keep looking */ + hay_ptr++; + } + + return NULL; /* no match anywhere in string */ +} + diff --git a/src/common/slurm_strcasestr.h b/src/common/slurm_strcasestr.h new file mode 100644 index 0000000000000000000000000000000000000000..79e7309093360eeaa96ccfa5da336a6b1a413bb9 --- /dev/null +++ b/src/common/slurm_strcasestr.h @@ -0,0 +1,46 @@ +/*****************************************************************************\ + * slurm_strcasestr.h - case insensitve version of strstr() + ***************************************************************************** + * Copyright (C) 2009 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by David Bremer <dbremer@llnl.gov> + * CODE-OCEC-09-009. All rights reserved. + * + * This file is part of SLURM, a resource management program. + * For details, see <https://computing.llnl.gov/linux/slurm/>. + * Please also read the included file: DISCLAIMER. + * + * SLURM 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. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * SLURM 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 SLURM; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#ifndef _SLURM_STRCASESTR_H +#define _SLURM_STRCASESTR_H + +/* case insensitve version of strstr(). This exists for our AIX + builds which are missing the gnu strcasestr function. */ +char *slurm_strcasestr(char *haystack, char *needle); + +#endif