r24701: Fix the swat build
authorVolker Lendecke <vlendec@samba.org>
Mon, 27 Aug 2007 11:41:05 +0000 (11:41 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:30:14 +0000 (12:30 -0500)
Swat has not been built by default for a while, so I did not notice that
the _ macro is actually used. Re-add the lang_msg_rotate function, this
time only to swat so that this is the only binary that has to take the
16k penalty.
(This used to be commit 191e1ef840c293f8575cc0a3f3ffba2080431fae)

source3/configure.in
source3/web/statuspage.c
source3/web/swat.c

index 0d0fdb1394582ac82f4958432d065ded5e71295d..6997106ffb0e0c5770ae4367d7e563462ae074b9 100644 (file)
@@ -354,21 +354,23 @@ AC_LIBREPLACE_CC_CHECKS
 
 m4_include(lib/socket_wrapper/config.m4)
 
+SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)'
+SWAT_INSTALL_TARGETS=installswat
 
 AC_ARG_ENABLE(swat,
 [  --enable-swat           Build the SWAT tool (default=yes)],
 [
     case "$enable_swat" in
-       no) ;;
-       *)
-           SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)'
-           SWAT_INSTALL_TARGETS=installswat
+       no)
+           SWAT_SBIN_TARGETS=''
+           SWAT_INSTALL_TARGETS=''
            ;;
     esac
-    AC_SUBST(SWAT_SBIN_TARGETS)
-    AC_SUBST(SWAT_INSTALL_TARGETS)
 ])
 
+AC_SUBST(SWAT_SBIN_TARGETS)
+AC_SUBST(SWAT_INSTALL_TARGETS)
+
 #################################################
 # set prefix for 'make test'
 selftest_prefix="./"
index f4f84cd239bfe57d88d015dca6e24aae43316820..e90a94d9e7fc0c5dc1cc0bcba888ee4c7a030cef 100644 (file)
@@ -20,6 +20,8 @@
 #include "includes.h"
 #include "web/swat_proto.h"
 
+#define _(x) lang_msg_rotate(x)
+
 #define PIDMAP         struct PidMap
 
 /* how long to wait for start/stops to take effect */
index 25dc9306ea63ce8ff54b2b716a2970753b12e3a0..d14e1bd1e9c47d6778b7fbcd715bf28eecbc01d4 100644 (file)
@@ -51,6 +51,7 @@ static int iNumNonAutoPrintServices = 0;
 #define ENABLE_USER_FLAG "enable_user_flag"
 #define RHOST "remote_host"
 
+#define _(x) lang_msg_rotate(x)
 
 /****************************************************************************
 ****************************************************************************/
@@ -1328,6 +1329,30 @@ static void printers_page(void)
        printf("</FORM>\n");
 }
 
+/*
+  when the _() translation macro is used there is no obvious place to free
+  the resulting string and there is no easy way to give a static pointer.
+  All we can do is rotate between some static buffers and hope a single d_printf()
+  doesn't have more calls to _() than the number of buffers
+*/
+
+const char *lang_msg_rotate(const char *msgid)
+{
+#define NUM_LANG_BUFS 16
+       char *msgstr;
+       static pstring bufs[NUM_LANG_BUFS];
+       static int next;
+
+       msgstr = (char *)lang_msg(msgid);
+       if (!msgstr) return msgid;
+
+       pstrcpy(bufs[next], msgstr);
+       msgstr = bufs[next];
+
+       next = (next+1) % NUM_LANG_BUFS;
+
+       return msgstr;
+}
 
 /**
  * main function for SWAT.