+Locale catalogs rewriting if --enable-bundle.
authorshort <>
Sun, 23 May 2004 18:27:39 +0000 (18:27 +0000)
committershort <>
Sun, 23 May 2004 18:27:39 +0000 (18:27 +0000)
src/Makefile.am
src/bundle-util.c
src/bundle-util.h
src/main.c
src/startup-chkconfig.c

index 8c4a7f5..dfba9e5 100644 (file)
@@ -76,7 +76,9 @@ udpgate_SOURCES= \
 EXTRA_DIST+= \
                $(GLADE_IN)
 
-udpgate_CFLAGS=-DSYSCONFDIR="$(sysconfdir)"
+udpgate_CFLAGS= \
+               -DSYSCONFDIR="$(sysconfdir)" \
+               -DCATALOGS="$(CATALOGS)"
 udpgate_LDADD=
 
 udpgate-ui-gnome-interface.$(OBJEXT): ui-gnome-callbacks.h
index 83057b2..59d1e06 100644 (file)
 
 #include "bundle-util.h"       /* self */
 #include "bundle.h"
+#include "main.h"
 
 
-static const guint8 *bundle_util_file_retrieve(guint32 *data_length_return,const gchar *pathname,const gchar *basename)
+static G_CONST_RETURN guint8 *bundle_util_file_retrieve(guint32 *data_length_return,const gchar *basename)
 {
 const guint8 *data;
 
        g_return_val_if_fail(data_length_return!=NULL,NULL);
-       g_return_val_if_fail(pathname!=NULL,NULL);
        g_return_val_if_fail(basename!=NULL,NULL);
 
+       if (optarg_verbose)
+               g_message(_("Retrieving internally stored: %s"),basename);
        data=g_hash_table_lookup(bundle_hash_new(),basename);
        g_return_val_if_fail(data!=NULL,NULL);
        *data_length_return=GUINT32_FROM_BE(*(guint32 *)data);
@@ -66,7 +68,7 @@ time_t time_current;
        g_return_val_if_fail(pathname!=NULL,FALSE);
        g_return_val_if_fail(basename!=NULL,FALSE);
 
-       if (!(data=bundle_util_file_retrieve(&data_length,pathname,basename)))
+       if (!(data=bundle_util_file_retrieve(&data_length,basename)))
                return FALSE;
 
        if (-1==(fd=open(pathname,O_RDONLY))) {
@@ -120,7 +122,7 @@ gboolean bundle_util_file_remove(const gchar *pathname,const gchar *basename)
        return TRUE;
 }
 
-gboolean bundle_util_file_write(const gchar *pathname,const gchar *basename,mode_t pathname_mode)
+gboolean bundle_util_file_write(const gchar *pathname,const gchar *basename,mode_t pathname_mode,gboolean pathname_backup)
 {
 const guint8 *data;
 guint32 data_length;
@@ -129,10 +131,10 @@ int fd;
        g_return_val_if_fail(pathname!=NULL,FALSE);
        g_return_val_if_fail(basename!=NULL,FALSE);
 
-       if (!(data=bundle_util_file_retrieve(&data_length,pathname,basename)))
+       if (!(data=bundle_util_file_retrieve(&data_length,basename)))
                return FALSE;
 
-       if (!bundle_util_file_backup_conditional(pathname,basename))
+       if (pathname_backup && !bundle_util_file_backup_conditional(pathname,basename))
                return FALSE;
 
        if (-1==(fd=open(pathname,O_WRONLY|O_CREAT|O_TRUNC,pathname_mode))) {
index 482f92f..cb58855 100644 (file)
@@ -27,7 +27,7 @@
 G_BEGIN_DECLS
 
 gboolean bundle_util_file_remove(const gchar *pathname,const gchar *basename);
-gboolean bundle_util_file_write(const gchar *pathname,const gchar *basename,mode_t pathname_mode);
+gboolean bundle_util_file_write(const gchar *pathname,const gchar *basename,mode_t pathname_mode,gboolean pathname_backup);
 
 G_END_DECLS
 
index 4e38270..6e4db2c 100644 (file)
@@ -38,6 +38,9 @@
 #include "network.h"
 #include "configuration.h"
 #include "startup.h"
+#ifdef ENABLE_BUNDLE
+#include "bundle-util.h"
+#endif
 
 #ifdef HAVE_GNOME
 #include "ui-gnome.h"
@@ -131,6 +134,34 @@ static void gnome_init_g_log_handler(const gchar *log_domain,GLogLevelFlags log_
 }
 #endif /* HAVE_GNOME */
 
+#ifdef ENABLE_BUNDLE
+static gboolean locale_files_write(void)
+{
+gchar catalogs[]=G_STRINGIFY(CATALOGS);
+gchar *catalog,*catalog_next;
+
+       for (catalog=catalogs;*catalog;catalog=catalog_next) {
+gchar *cc,*cc_end;
+
+               for (catalog_next=catalog;*catalog_next && *catalog_next!=' ';catalog_next++);
+               if (*catalog_next)
+                       *catalog_next++='\0';
+               cc=g_strdup(catalog);
+               cc_end=cc+strlen(cc)-strlen(".gmo");
+               if (!strcmp(cc_end,".gmo")) {   /* errors ignored */
+                       *cc_end='\0';
+                       bundle_util_file_write( /* errors ignored */
+                                       udpgate_printf_alloca("%s/%s/LC_MESSAGES/%s.mo",LOCALEDIR,cc,PACKAGE),  /* pathname */
+                                       catalog,        /* basename */
+                                       0644,   /* pathname_mode */
+                                       FALSE); /* pathname_backup */
+                       }
+               g_free(cc);
+               }
+       return FALSE;
+}
+#endif /* ENABLE_BUNDLE */
+
 int main(int argc,char **argv)
 {
 poptContext context;
@@ -141,6 +172,10 @@ gboolean no_gnome;
 #endif /* HAVE_GNOME */
 int exit_rc=EXIT_SUCCESS;
 
+#ifdef ENABLE_BUNDLE
+       locale_files_write();
+#endif /* ENABLE_BUNDLE */
+
 #if 0
        g_log_set_always_fatal(~(0
                        |G_LOG_LEVEL_MESSAGE
index c397f46..79a610b 100644 (file)
@@ -94,7 +94,11 @@ const gchar *command="chkconfig --add " PACKAGE;
                return FALSE;
 
 #ifdef ENABLE_BUNDLE
-       if (!bundle_util_file_write(INIT_D_PATHNAME,PACKAGE ".init",0755))
+       if (!bundle_util_file_write(
+                       INIT_D_PATHNAME,        /* pathname */
+                       PACKAGE ".init",        /* basename */
+                       0755,   /* pathname_mode */
+                       TRUE))  /* pathname_backup */
                return FALSE;
 #endif /* ENABLE_BUNDLE */
        status=system(command);