From ee1ba3209993b72e90f5fe30a16ad951f1e2402d Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Thu, 17 Oct 2024 17:57:50 +0200 Subject: lib: clang-format --- lib/extra_opts.c | 149 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 77 insertions(+), 72 deletions(-) (limited to 'lib/extra_opts.c') diff --git a/lib/extra_opts.c b/lib/extra_opts.c index 771621d8..82460e92 100644 --- a/lib/extra_opts.c +++ b/lib/extra_opts.c @@ -1,24 +1,24 @@ /***************************************************************************** -* -* Monitoring Plugins extra_opts library -* -* License: GPL -* Copyright (c) 2007 Monitoring Plugins Development Team -* -* 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 3 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, see . -* -*****************************************************************************/ + * + * Monitoring Plugins extra_opts library + * + * License: GPL + * Copyright (c) 2007 Monitoring Plugins Development Team + * + * 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 3 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, see . + * + *****************************************************************************/ #include "common.h" #include "utils_base.h" @@ -26,110 +26,115 @@ #include "extra_opts.h" /* FIXME: copied from utils.h; we should move a bunch of libs! */ -bool is_option2 (char *str) -{ +bool is_option2(char *str) { if (!str) return false; - else if (strspn (str, "-") == 1 || strspn (str, "-") == 2) + else if (strspn(str, "-") == 1 || strspn(str, "-") == 2) return true; else return false; } /* this is the externally visible function used by plugins */ -char **np_extra_opts(int *argc, char **argv, const char *plugin_name){ - np_arg_list *extra_args=NULL, *ea1=NULL, *ea_tmp=NULL; - char **argv_new=NULL; - char *argptr=NULL; - int i, j, optfound, argc_new, ea_num=*argc; +char **np_extra_opts(int *argc, char **argv, const char *plugin_name) { + np_arg_list *extra_args = NULL, *ea1 = NULL, *ea_tmp = NULL; + char **argv_new = NULL; + char *argptr = NULL; + int i, j, optfound, argc_new, ea_num = *argc; - if(*argc<2) { + if (*argc < 2) { /* No arguments provided */ return argv; } - for(i=1; i<*argc; i++){ - argptr=NULL; - optfound=0; + for (i = 1; i < *argc; i++) { + argptr = NULL; + optfound = 0; /* Do we have an extra-opts parameter? */ - if(strncmp(argv[i], "--extra-opts=", 13)==0){ + if (strncmp(argv[i], "--extra-opts=", 13) == 0) { /* It is a single argument with value */ - argptr=argv[i]+13; + argptr = argv[i] + 13; /* Delete the extra opts argument */ - for(j=i;j<*argc;j++) argv[j]=argv[j+1]; + for (j = i; j < *argc; j++) + argv[j] = argv[j + 1]; i--; - *argc-=1; - }else if(strcmp(argv[i], "--extra-opts")==0){ - if((i+1<*argc)&&!is_option2(argv[i+1])){ + *argc -= 1; + } else if (strcmp(argv[i], "--extra-opts") == 0) { + if ((i + 1 < *argc) && !is_option2(argv[i + 1])) { /* It is a argument with separate value */ - argptr=argv[i+1]; + argptr = argv[i + 1]; /* Delete the extra-opts argument/value */ - for(j=i;j<*argc-1;j++) argv[j]=argv[j+2]; - i-=2; - *argc-=2; + for (j = i; j < *argc - 1; j++) + argv[j] = argv[j + 2]; + i -= 2; + *argc -= 2; ea_num--; - }else{ + } else { /* It has no value */ - optfound=1; + optfound = 1; /* Delete the extra opts argument */ - for(j=i;j<*argc;j++) argv[j]=argv[j+1]; + for (j = i; j < *argc; j++) + argv[j] = argv[j + 1]; i--; - *argc-=1; + *argc -= 1; } } /* If we found extra-opts, expand them and store them for later*/ - if(argptr||optfound){ + if (argptr || optfound) { /* Process ini section, returning a linked list of arguments */ - ea1=np_get_defaults(argptr, plugin_name); - if(ea1==NULL) { + ea1 = np_get_defaults(argptr, plugin_name); + if (ea1 == NULL) { /* no extra args (empty section)? */ ea_num--; continue; } /* append the list to extra_args */ - if(extra_args==NULL){ - extra_args=ea1; - while((ea1 = ea1->next)) ea_num++; - }else{ - ea_tmp=extra_args; - while(ea_tmp->next) { - ea_tmp=ea_tmp->next; + if (extra_args == NULL) { + extra_args = ea1; + while ((ea1 = ea1->next)) + ea_num++; + } else { + ea_tmp = extra_args; + while (ea_tmp->next) { + ea_tmp = ea_tmp->next; } - ea_tmp->next=ea1; - while((ea1 = ea1->next)) ea_num++; + ea_tmp->next = ea1; + while ((ea1 = ea1->next)) + ea_num++; } - ea1=ea_tmp=NULL; + ea1 = ea_tmp = NULL; } } /* lather, rince, repeat */ - if(ea_num==*argc && extra_args==NULL){ + if (ea_num == *argc && extra_args == NULL) { /* No extra-opts */ return argv; } /* done processing arguments. now create a new argv array... */ - argv_new=(char**)malloc((ea_num+1)*sizeof(char**)); - if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n")); + argv_new = (char **)malloc((ea_num + 1) * sizeof(char **)); + if (argv_new == NULL) + die(STATE_UNKNOWN, _("malloc() failed!\n")); /* starting with program name */ - argv_new[0]=argv[0]; - argc_new=1; + argv_new[0] = argv[0]; + argc_new = 1; /* then parsed ini opts (frying them up in the same run) */ - while(extra_args){ - argv_new[argc_new++]=extra_args->arg; - ea1=extra_args; - extra_args=extra_args->next; + while (extra_args) { + argv_new[argc_new++] = extra_args->arg; + ea1 = extra_args; + extra_args = extra_args->next; free(ea1); } /* finally the rest of the argv array */ - for (i=1; i<*argc; i++) argv_new[argc_new++]=argv[i]; - *argc=argc_new; + for (i = 1; i < *argc; i++) + argv_new[argc_new++] = argv[i]; + *argc = argc_new; /* and terminate. */ - argv_new[argc_new]=NULL; + argv_new[argc_new] = NULL; return argv_new; } - -- cgit v1.2.3-74-g34f1 From 9462819774ed2e3f51c75fffda59724428205c0e Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Thu, 17 Oct 2024 18:01:49 +0200 Subject: lib: Update copyright --- lib/extra_opts.c | 2 +- lib/maxfd.c | 20 ++++++++++++++++++++ lib/parse_ini.c | 2 +- lib/utils_base.c | 2 +- lib/utils_cmd.c | 2 +- lib/utils_cmd.h | 1 - lib/utils_disk.c | 2 +- lib/utils_tcp.c | 2 +- 8 files changed, 26 insertions(+), 7 deletions(-) (limited to 'lib/extra_opts.c') diff --git a/lib/extra_opts.c b/lib/extra_opts.c index 82460e92..88787336 100644 --- a/lib/extra_opts.c +++ b/lib/extra_opts.c @@ -3,7 +3,7 @@ * Monitoring Plugins extra_opts library * * License: GPL - * Copyright (c) 2007 Monitoring Plugins Development Team + * Copyright (c) 2007 - 2024 Monitoring Plugins Development Team * * 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 diff --git a/lib/maxfd.c b/lib/maxfd.c index c39d427c..ca5b6e54 100644 --- a/lib/maxfd.c +++ b/lib/maxfd.c @@ -1,3 +1,23 @@ +/***************************************************************************** + * + * License: GPL + * Copyright (c) 2024 Monitoring Plugins Development Team + * + * 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 3 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, see . + * + *****************************************************************************/ + #include "./maxfd.h" #include diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 150df7b2..873ee8ce 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c @@ -3,7 +3,7 @@ * Monitoring Plugins parse_ini library * * License: GPL - * Copyright (c) 2007 Monitoring Plugins Development Team + * Copyright (c) 2007 - 2024 Monitoring Plugins Development Team * * 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 diff --git a/lib/utils_base.c b/lib/utils_base.c index cd135836..6d6954ef 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -3,7 +3,7 @@ * utils_base.c * * License: GPL - * Copyright (c) 2006 Monitoring Plugins Development Team + * Copyright (c) 2006 - 2024 Monitoring Plugins Development Team * * Library of useful functions for plugins * diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 25d56785..416cf824 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c @@ -3,7 +3,7 @@ * Monitoring run command utilities * * License: GPL - * Copyright (c) 2005-2006 Monitoring Plugins Development Team + * Copyright (c) 2005-2024 Monitoring Plugins Development Team * * Description : * diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index 0fc09173..d00069c9 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h @@ -4,7 +4,6 @@ /* * Header file for Monitoring Plugins utils_cmd.c * - * */ /** types **/ diff --git a/lib/utils_disk.c b/lib/utils_disk.c index a317f7da..c87090e8 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -3,7 +3,7 @@ * Library for check_disk * * License: GPL - * Copyright (c) 1999-2007 Monitoring Plugins Development Team + * Copyright (c) 1999-2024 Monitoring Plugins Development Team * * Description: * diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c index ffb351e6..440eb9b4 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c @@ -3,7 +3,7 @@ * Library for check_tcp * * License: GPL - * Copyright (c) 1999-2013 Monitoring Plugins Development Team + * Copyright (c) 1999-2024 Monitoring Plugins Development Team * * Description: * -- cgit v1.2.3-74-g34f1