[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2] Englische Übersetzung für servmgr



Signed-off-by: Patrick Pokatilo <shyxormz@xxxxxxxxxx>
---
 src/modules/servmgr/Makefile.all       |    2 +-
 src/modules/servmgr/config.c           |   13 ++++--
 src/modules/servmgr/lang/Makefile.conf |    1 +
 src/modules/servmgr/lang/lang_en.c     |   70 ++++++++++++++++++++++++++++++++
 src/modules/servmgr/lang/resstr.h      |   42 +++++++++++++++++++
 src/modules/servmgr/main.c             |   11 ++++-
 src/modules/servmgr/service.c          |   13 ++++--
 7 files changed, 139 insertions(+), 13 deletions(-)
 create mode 100644 src/modules/servmgr/lang/Makefile.conf
 create mode 100644 src/modules/servmgr/lang/lang_en.c
 create mode 100644 src/modules/servmgr/lang/resstr.h

diff --git a/src/modules/servmgr/Makefile.all b/src/modules/servmgr/Makefile.all
index 59b7be6..39630b1 100644
--- a/src/modules/servmgr/Makefile.all
+++ b/src/modules/servmgr/Makefile.all
@@ -2,5 +2,5 @@ shopt -s extglob
 source $LOST_BUILDMK_ROOT/config.sh
 
 echo "LD   $1/modules/servmgr"
-$LOST_TOOLS_LD $LDSCRIPT -oservmgr.mod  *.o --start-group $2 --end-group
+$LOST_TOOLS_LD $LDSCRIPT -oservmgr.mod  *.o lang/*.o --start-group $2 --end-group
 $LOST_TOOLS_STRIP -s servmgr.mod -o $1/modules/servmgr
diff --git a/src/modules/servmgr/config.c b/src/modules/servmgr/config.c
index 2280e00..434eacc 100644
--- a/src/modules/servmgr/config.c
+++ b/src/modules/servmgr/config.c
@@ -45,6 +45,9 @@
 #include <sleep.h>
 #include "servmgr.h"
 
+#define TMS_MODULE config
+#include <tms.h>
+
 static list_t* config_list;
 char* full_config_path;
 
@@ -159,9 +162,9 @@ static void config_parse_deps(const char* path,
 
         dep = config_service_get(buffer);
         if (dep == NULL) {
-            printf("servmgr: Service %s haengt ab von %s; Dieser ist aber "
-                "nicht vorhanden in der Konfiguration!\n", conf_serv->name,
-                buffer);
+            printf(TMS(service_depends, "servmgr: Service '%s' haengt ab von "
+                "'%s'; Dieser ist aber nicht vorhanden in der "
+                "Konfiguration!\n"), conf_serv->name, buffer);
             continue;
         }
 
@@ -286,8 +289,8 @@ bool config_read()
     // Verzeichnis mit der Konfiguration oeffnen
     dir = directory_open(full_config_path);
     if (!dir) {
-        printf("servmgr: Konnte Konfigurationsverzeichnis nicht oeffnen: '%s'"
-            "\n", full_config_path);
+        printf(TMS(dir_open, "servmgr: Konnte Konfigurationsverzeichnis nicht "
+            "oeffnen: '%s'\n"), full_config_path);
         return false;
     }
 
diff --git a/src/modules/servmgr/lang/Makefile.conf b/src/modules/servmgr/lang/Makefile.conf
new file mode 100644
index 0000000..594ef2a
--- /dev/null
+++ b/src/modules/servmgr/lang/Makefile.conf
@@ -0,0 +1 @@
+CC_FLAGS_APPEND="-Wno-missing-braces"
diff --git a/src/modules/servmgr/lang/lang_en.c b/src/modules/servmgr/lang/lang_en.c
new file mode 100644
index 0000000..11ed0b0
--- /dev/null
+++ b/src/modules/servmgr/lang/lang_en.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Pokatilo.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <tms.h>
+#include "resstr.h"
+
+static int get_number(int n)
+{
+    return (n == 1 ? 0 : 1);
+}
+
+static const struct tms_strings dict[] = {
+    &__tms_config_service_depends,
+    "servmgr: service '%s' depends on '%s', which is not present in the configuration!\n",
+
+    &__tms_config_dir_open,
+    "servmgr: could not open configuration directory: '%s'\n",
+
+    &__tms_main_usage,
+    "usage: servmgr <root directory> <service terminal> [startup services ...]\n",
+
+    &__tms_main_not_running,
+    "service '%s' is not running!\n",
+
+    &__tms_service_not_found,
+    "servmgr: service not found: '%s'\n",
+
+    &__tms_service_dependency,
+    "servmgr: could not resolve dependency on '%s'. Thus, '%s' can not be started.\n",
+
+    &__tms_service_timeout,
+    "servmgr: timeout while waiting for service '%s'\n",
+
+    0,
+    0,
+};
+
+static const struct tms_lang lang = {
+    .lang = "en",
+    .numbers = 2,
+    .get_number = get_number,
+    .strings = dict,
+};
+
+LANGUAGE(&lang)
diff --git a/src/modules/servmgr/lang/resstr.h b/src/modules/servmgr/lang/resstr.h
new file mode 100644
index 0000000..8c6d536
--- /dev/null
+++ b/src/modules/servmgr/lang/resstr.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Pokatilo.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL;
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO;
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY;
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RESSTR_H
+#define RESSTR_H
+
+extern void* __tms_config_service_depends;
+extern void* __tms_config_dir_open;
+
+extern void* __tms_main_usage;
+extern void* __tms_main_not_running;
+
+extern void* __tms_service_not_found;
+extern void* __tms_service_dependency;
+extern void* __tms_service_timeout;
+
+#endif
diff --git a/src/modules/servmgr/main.c b/src/modules/servmgr/main.c
index a432208..87bd280 100644
--- a/src/modules/servmgr/main.c
+++ b/src/modules/servmgr/main.c
@@ -43,6 +43,9 @@
 
 #include "servmgr.h"
 
+#define TMS_MODULE main
+#include <tms.h>
+
 bool service_running(const char* name);
 bool service_wait(const char* name, uint32_t timeout);
 
@@ -80,8 +83,8 @@ static void parse_params(int argc, char* argv[])
             list_push(startup_services, argv[i]);
         }
     } else {
-        puts("Aufruf: servmgr <Root-Verzeichnis> <Service-Terminal>"
-            "[Startup-Services ...]");
+        puts(TMS(usage, "Aufruf: servmgr <Root-Verzeichnis> <Service-Terminal>"
+            "[Startup-Services ...]\n"));
         exit(-1);
     }
 }
@@ -127,7 +130,7 @@ static void failed_startup_services(void)
     int i;
 
     for (i = 0; (service = list_get_element_at(startup_services, i)); i++) {
-        printf("Service '%s' laeuft nicht!\n", service);
+        printf(TMS(not_running, "Service '%s' läuft nicht!\n"), service);
     }
 }
 
@@ -140,6 +143,8 @@ static void failed_startup_services(void)
  */
 int main(int argc, char* argv[])
 {
+    tms_init();
+
     // Parameter verarbeiten
     parse_params(argc, argv);
 
diff --git a/src/modules/servmgr/service.c b/src/modules/servmgr/service.c
index 65e9f5d..a416ddb 100644
--- a/src/modules/servmgr/service.c
+++ b/src/modules/servmgr/service.c
@@ -42,6 +42,9 @@
 
 #include "servmgr.h"
 
+#define TMS_MODULE service
+#include <tms.h>
+
 /**
  * Pid eines Services anhand seines Namens finden
  *
@@ -107,15 +110,16 @@ bool service_start(const char* name)
     }
 
     if (!conf_serv) {
-        printf("servmgr: Service nicht gefunden: %s\n", name);
+        printf(TMS(not_found, "servmgr: Service nicht gefunden: '%s'\n"), name);
         return false;
     }
 
     // Abhaengigkeiten starten
     for (i = 0; (dep = list_get_element_at(conf_serv->deps, i)); i++) {
         if (!service_start(dep->name)) {
-            printf("servmgr: Konnte die Abhaengigkeit von %s nicht erfuellen. "
-                "%s kann deshalb nicht gestartet werden.\n", dep->name, name);
+            printf(TMS(dependency, "servmgr: Konnte die Abhängigkeit von %s "
+                "nicht erfüllen. '%s' kann deshalb nicht gestartet werden.\n"),
+                dep->name, name);
             return false;
         }
     }
@@ -123,7 +127,8 @@ bool service_start(const char* name)
     if (conf_serv->start_cmd) {
         pid_t pid = init_execute(conf_serv->start_cmd);
         if ((conf_serv->conf.wait == SERVSTART) && !service_wait(name, 10000)) {
-            printf("servmgr: Timeout beim Warten auf den Service %s\n", name);
+            printf(TMS(timeout, "servmgr: Timeout beim Warten auf den "
+                "Service '%s'\n"), name);
             return false;
         } else if (conf_serv->conf.wait == TERMINATE) {
             int status;
-- 
1.7.0.4