Code

Delete obsolete files
[nagiosplug.git] / lib / extra_opts.c
index e4251215abf467102972e36723fa133386932a47..8c17fa4ae37eb07f187f671d1c37f27e47ffdb59 100644 (file)
@@ -32,7 +32,7 @@
 
 /* FIXME: copied from utils.h; we should move a bunch of libs! */
 int
-is_option (char *str)
+is_option2 (char *str)
 {
        if (!str)
                return 0;
@@ -67,7 +67,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){
                        i--;
                        *argc-=1;
                }else if(strcmp(argv[i], "--extra-opts")==0){
-                       if(!is_option(argv[i+1])){
+                       if((i+1<*argc)&&!is_option2(argv[i+1])){
                                /* It is a argument with separate value */
                                argptr=argv[i+1];
                                /* Delete the extra-opts argument/value */
@@ -122,7 +122,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){
        if(argv_new==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n"));
 
        /* starting with program name */
-       argv_new[0]=strdup(argv[0]);
+       argv_new[0]=argv[0];
        argc_new=1;
        /* then parsed ini opts (frying them up in the same run) */
        while(extra_args){
@@ -132,7 +132,7 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name){
                free(ea1);
        }
        /* finally the rest of the argv array */
-       for (i=1; i<*argc; i++) argv_new[argc_new++]=strdup(argv[i]);
+       for (i=1; i<*argc; i++) argv_new[argc_new++]=argv[i];
        *argc=argc_new;
        /* and terminate. */
        argv_new[argc_new]=NULL;