From 1f76315bb26725154e149cfffe84f4f1020b3188 Mon Sep 17 00:00:00 2001
From: Victor Kotlyar <Victor.Kotlyar@cern.ch>
Date: Thu, 6 Jun 2019 11:47:30 +0200
Subject: [PATCH] Convert getopt to getopt_long in cta-smc.

To use the same command notation as cta-admin commands cta-smc
recognize long notations.
---
 mediachanger/castorrmc/rmc/smc.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mediachanger/castorrmc/rmc/smc.c b/mediachanger/castorrmc/rmc/smc.c
index df472ca885..52669b475f 100644
--- a/mediachanger/castorrmc/rmc/smc.c
+++ b/mediachanger/castorrmc/rmc/smc.c
@@ -14,6 +14,7 @@
 #include "serrno.h"
 #include "smc_constants.h"
 #include "getconfent.h"
+#include "getopt.h"
 
 #include <ctype.h>
 			/* exit codes */
@@ -437,9 +438,21 @@ int main(const int argc,
         int isJsonEnabled = 0;
 
 	/* parse and check command options */
-
+        struct option longopts [] = {
+          {"drive",  required_argument, NULL, 'D'},
+          {"dismount",     no_argument, NULL, 'd'},
+          {"export",       no_argument, NULL, 'e'},
+          {"import",       no_argument, NULL, 'i'},
+          {"mount",        no_argument, NULL, 'm'},
+          {"nbelem", required_argument, NULL, 'N'},
+          {"query",  required_argument, NULL, 'q'},
+          {"slot",   required_argument, NULL, 'S'},
+          {"vid",    required_argument, NULL, 'V'},
+          {"json",         no_argument, NULL, 'j'},
+          {NULL,                     0, NULL,   0}
+        };
 	memset (vid, '\0', sizeof(vid));
-	while ((c = getopt (argc, argv, "D:deimN:q:S:V:j")) != EOF) {
+	while ((c = getopt_long(argc, argv, "D:deimN:q:S:V:j", longopts, NULL)) != EOF) {
 		switch (c) {
 		case 'D':	/* drive ordinal */
 			drvord = strtol (optarg, &dp, 10);
-- 
GitLab