]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix localization issue on windows guests.
authorOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:31:37 +0000 (11:31 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 1 Apr 2020 18:31:37 +0000 (11:31 -0700)
Some fields of GOptionContext used in help are not public, so add 2
arguments to Usage to get needed info.

open-vm-tools/vgauth/cli/l10n/de.vmsg
open-vm-tools/vgauth/cli/l10n/en.vmsg
open-vm-tools/vgauth/cli/l10n/es.vmsg
open-vm-tools/vgauth/cli/l10n/fr.vmsg
open-vm-tools/vgauth/cli/l10n/it.vmsg
open-vm-tools/vgauth/cli/l10n/ja.vmsg
open-vm-tools/vgauth/cli/l10n/ko.vmsg
open-vm-tools/vgauth/cli/l10n/zh_CN.vmsg
open-vm-tools/vgauth/cli/l10n/zh_TW.vmsg
open-vm-tools/vgauth/cli/main.c

index 6e838445d92155d43f0a1a60758e7b3313e7505c..aa65fa6f3bf4c1864d92d9ecd6c58148c22eb225 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "Benutzer, dessen Zertifikatsspeicher hinzugefügt wird zu
 
 addoptions.verbose = "Detaillierter Vorgang"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "Die Analyse der Befehlszeile ist fehlgeschlagen"
 
 cmdline.summary.pemfile = "PEM-Datei"
index 20306720c3413f4825d64c1f63634c060f2a257b..b3d91876b7191e1482e4183aabdf21530ed17348 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "User whose certificate store is being added to"
 
 addoptions.verbose = "Verbose operation"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "Command line parsing failed"
 
 cmdline.summary.pemfile = "PEM-file"
index c4c499e3b1ab2745fe1644f9cb5332fcea657260..8a773367b1433059e2ef09db8034c2c0f3e48871 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "El usuario cuyo almacén de certificados se está añadie
 
 addoptions.verbose = "Operación detallada"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "Error de análisis de línea de comando"
 
 cmdline.summary.pemfile = "Archivo PEM"
index 6147d413993bbe75dce2685da7180a51a713c638..6be5f26ae983ff39a8defafafc349e5df1f2df68 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "Utilisateur dont le magasin de certificats est ajouté à
 
 addoptions.verbose = "Opération en mode détaillé"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "Échec de l'analyse de la ligne de commande"
 
 cmdline.summary.pemfile = "Fichier PEM"
index 34b35f7a035d70d969ba87131fc74d09b6c02056..46dd3fab5e2ecae71d5205b0505b9d15d2379a85 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2018 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2018,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "Utente a cui viene aggiunto l'archivio certificati"
 
 addoptions.verbose = "Operazione Verbose"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "Analisi della riga di comando non riuscita"
 
 cmdline.summary.pemfile = "File PEM"
index 2bee2fba5090a6e84713306e5e66ca5ac9de753a..028d74dd39189cd37507a5a30e18fb259e3faa91 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "証明書ストアが追加されているユーザー"
 
 addoptions.verbose = "詳細な操作"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "コマンド ラインの解析に失敗しました"
 
 cmdline.summary.pemfile = "PEM ファイル"
index 23603f35ac6927f998bbdb23d8f38e20822dfe53..aaa51e2d8054c821699d90790491241a01a79bec 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "인증서 저장소를 추가 중인 사용자"
 
 addoptions.verbose = "자세한 정보 표시 작업"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "명령줄 구문 분석 실패"
 
 cmdline.summary.pemfile = "PEM 파일"
index 7c97afbaf81e0ef6480defebadbf7882e5f1e209..954f22f4538c1a7ee6bc9efebb1b9f0d61d7cc1e 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "要在以下位置添加证书存储的用户"
 
 addoptions.verbose = "详细操作"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "命令行分析失败"
 
 cmdline.summary.pemfile = "PEM 文件"
index 164bd3c87a1857e0675f5a0fccc4f621e0aac61d..f6519ff0f061f7f15503fa6b1b5144bb7637a3c4 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################
-# Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+# Copyright (C) 2011-2017,2020 VMware, Inc. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU Lesser General Public License as published
@@ -31,7 +31,10 @@ addoptions.username = "正將其憑證存放區新增至以下項目的使用者
 
 addoptions.verbose = "詳細資訊作業"
 
-
+cmdline.help.appoption = "Application Options"
+cmdline.help.helpoption = "Help Options"
+cmdline.help.hint = "Show help options"
+cmdline.help.usage = "Usage"
 cmdline.parse = "命令行剖析失敗"
 
 cmdline.summary.pemfile = "PEM 檔案"
index 7561699a60a777718259d84f9e60dd70293c5e72..899d7dd63779beed94685f0ba12a3ee3204e1ef5 100644 (file)
@@ -47,6 +47,82 @@ static gchar *appName;
 static gboolean verbose = FALSE;
 
 
+#ifdef _WIN32
+
+
+/*
+ ******************************************************************************
+ * GetHelp --                                                            */ /**
+ *
+ * Get help message for CLI on windows
+ *
+ * @param[in] context      The GOptionContext for generating the message
+ * @param[in] paramStr     The command line operation arguments
+ * @param[in] cmdOptions   The command line options for given operation
+ *
+ ******************************************************************************
+ */
+
+static gchar *
+GetHelp(GOptionContext *context,
+        const char *paramStr,
+        const GOptionEntry *cmdOptions)
+{
+   gchar *helpMsg;
+   const gchar *lUsage = SU_(cmdline.help.usage, "Usage");
+   const gchar *lHelpOption = SU_(cmdline.help.helpoption, "Help Options");
+   const gchar *lAppOption = SU_(cmdline.help.appoption, "Application Options");
+   const gchar *lHint = SU_(cmdline.help.hint, "Show help options");
+
+   if (cmdOptions == NULL){
+      helpMsg = g_strdup_printf("%s:\n"
+                                "  %s %s\n\n"
+                                "%s\n\n"
+                                "%s:\n"
+                                "  -h, --help       %s\n",
+                                lUsage,
+                                appName, paramStr,
+                                g_option_context_get_summary(context),
+                                lHelpOption,
+                                lHint);
+   } else {
+      gchar *optionMsg;
+      GString *optStr;
+      int i;
+      optStr = g_string_new(NULL);
+      for (i = 0; cmdOptions[i].long_name != NULL; i++) {
+         g_string_append_printf(optStr,
+                                "  -%c, --%-8s    %s\n",
+                                cmdOptions[i].short_name,
+                                cmdOptions[i].long_name,
+                                cmdOptions[i].description);
+      }
+      optionMsg = g_string_free(optStr, FALSE);
+
+      helpMsg = g_strdup_printf("%s:\n"
+                                "  %s %s\n\n"
+                                "%s\n\n"
+                                "%s:\n"
+                                "  -h, --help       %s\n"
+                                "%s:\n"
+                                "%s",
+                                lUsage,
+                                appName, paramStr,
+                                g_option_context_get_summary(context),
+                                lHelpOption,
+                                lHint,
+                                lAppOption,
+                                optionMsg);
+      g_free(optionMsg);
+   }
+
+   return helpMsg;
+}
+
+#endif
+
+
+
 /*
  ******************************************************************************
  * Usage --                                                              */ /**
@@ -54,16 +130,24 @@ static gboolean verbose = FALSE;
  * Usage message for CLI
  *
  * @param[in] optContext   The GOptionContext for generating the message
+ * @param[in] paramStr     The command line operation arguments
+ * @param[in] cmdOptions   The command line options for given operation
  *
  ******************************************************************************
  */
 
 static void
-Usage(GOptionContext *optContext)
+Usage(GOptionContext *optContext,
+      const char *paramStr,
+      const GOptionEntry *cmdOptions)
 {
    gchar *usage;
-
+#ifdef _WIN32
+   usage = GetHelp(optContext, paramStr, cmdOptions);
+#else
    usage = g_option_context_get_help(optContext, TRUE, NULL);
+#endif
+
    g_printerr("%s", usage);
    g_free(usage);
    exit(-1);
@@ -456,6 +540,8 @@ mainRun(int argc,
    gchar *comment = NULL;
    gchar *summaryMsg;
    gchar *subject = NULL;
+   GOptionEntry *cmdOptions = NULL;
+   const gchar *paramStr = "[add | list | remove]\n";
    const gchar *lUsername = SU_(cmdline.summary.username, "username");
    const gchar *lSubject = SU_(cmdline.summary.subject, "subject");
    const gchar *lPEMfile = SU_(cmdline.summary.pemfile, "PEM-file");
@@ -463,7 +549,6 @@ mainRun(int argc,
 
 #if (use_glib_parser == 0)
    int i;
-   GOptionEntry *cmdOptions;
 #else
    GError *gErr = NULL;
 #endif
@@ -521,7 +606,7 @@ mainRun(int argc,
     * Set up the option parser
     */
    g_set_prgname(appName);
-   context = g_option_context_new("[add | list | remove]\n");
+   context = g_option_context_new(paramStr);
    summaryMsg = g_strdup_printf(
       "add --global --username=%s --file=%s --subject=%s "
              "[ --comment=%s ]\n"
@@ -534,7 +619,7 @@ mainRun(int argc,
    g_option_context_set_summary(context, summaryMsg);
    g_free(summaryMsg);
    if (argc < 2) {
-      Usage(context);
+      Usage(context, paramStr, cmdOptions);
    }
 
    /*
@@ -543,31 +628,25 @@ mainRun(int argc,
    if (strcmp(argvCopy[1], "add") == 0) {
       doAdd = TRUE;
       g_option_context_add_main_entries(context, addOptions, NULL);
-#if (use_glib_parser == 0)
       cmdOptions = addOptions;
-#endif
    } else if (strcmp(argvCopy[1], "remove") == 0) {
       doRemove = TRUE;
       g_option_context_add_main_entries(context, removeOptions, NULL);
-#if (use_glib_parser == 0)
       cmdOptions = removeOptions;
-#endif
    } else if (strcmp(argvCopy[1], "list") == 0) {
       doList = TRUE;
       g_option_context_add_main_entries(context, listOptions, NULL);
-#if (use_glib_parser == 0)
       cmdOptions = listOptions;
-#endif
    } else {
-      Usage(context);
+      Usage(context, paramStr, cmdOptions);
    }
 
 #if (use_glib_parser == 0)
    /*
-    * In Windows, g_option_context_parse() does the wrong thing for locale
-    * conversion of the incoming Unicode cmdline.  Modern glib (2.40 or
-    * later) solves this with g_option_context_parse_strv(), but we're stuck
-    * with an older glib for now.
+    * In Windows, g_option_context_parse() does the wrong thing for the
+    * incoming Unicode cmdline.  Modern glib (2.40 or later) solves this
+    * with g_option_context_parse_strv(), but we're stuck with an older
+    * glib for now.
     *
     * So instead lets do it all by hand.
     *
@@ -599,14 +678,14 @@ mainRun(int argc,
                   *(gchar **) e->arg_data = argv[++i];
                   match = TRUE;
                } else {
-                  Usage(context);
+                  Usage(context, paramStr, cmdOptions);
                }
             } else if (e->arg == G_OPTION_ARG_NONE) {
                *(gboolean *) e->arg_data = TRUE;
                match = TRUE;
             }
          } else if (strncmp(longName, argv[i], len) == 0 &&
-                    (argv[i][len] == '=' || argv[i][len] == '\0')) {
+                   (argv[i][len] == '=' || argv[i][len] == '\0')) {
             gchar *val = NULL;
 
             if (e->arg == G_OPTION_ARG_STRING) {
@@ -621,7 +700,7 @@ mainRun(int argc,
                *(gboolean *) e->arg_data = TRUE;
                match = TRUE;
             } else {
-               Usage(context);
+               Usage(context, paramStr, cmdOptions);
             }
          }
          if (match) {
@@ -631,7 +710,7 @@ mainRun(int argc,
       }
 next:
       if (!match) {
-         Usage(context);
+         Usage(context, paramStr, cmdOptions);
       }
    }
 #else
@@ -648,7 +727,7 @@ next:
     * XXX pull this if we use stdin for the cert contents.
     */
    if ((doAdd || doRemove) && !pemFilename) {
-      Usage(context);
+      Usage(context, paramStr, cmdOptions);
    }
 
    err = VGAuth_Init(appName, 0, NULL, &ctx);