]> arthur.barton.de Git - netatalk.git/blobdiff - etc/atalkd/config.c
Remove a lot of warning, from cvs HEAD
[netatalk.git] / etc / atalkd / config.c
index 675949a66825c6fccf7d1dc8972e6624c7fd4b58..2989bb1429967c3bdeb0c06081be6233de23c20d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: config.c,v 1.13.6.2 2004-01-15 06:34:15 bfernhomberg Exp $
+ * $Id: config.c,v 1.13.6.5.2.4 2005-09-27 10:40:41 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved. See COPYRIGHT.
@@ -55,6 +55,7 @@ char *strchr (), *strrchr ();
 #include <sys/stropts.h>
 #endif /* __svr4__ */
 
+#include <atalk/unicode.h>
 #include "interface.h"
 #include "multicast.h"
 #include "rtmp.h"
@@ -68,7 +69,7 @@ char *strchr (), *strrchr ();
 
 int    router(), dontroute(), seed(), phase(), net(), addr(), zone(), noallmulti();
 
-static struct param {
+static const struct param {
     char       *p_name;
     int                (*p_func)();
 } params[] = {
@@ -187,6 +188,8 @@ int writeconf( cf )
     struct interface   *iface;
     struct list                *l;
     int                        mode = 0644, fd;
+    size_t             len;
+    char               *zonename;
 
     if ( cf == NULL ) {
        path = _PATH_ATALKDCONF;
@@ -245,9 +248,11 @@ int writeconf( cf )
            if ( iface->i_flags & IFACE_DONTROUTE) {
                fprintf( newconf, " -dontroute");
            }
+#ifdef linux
             if ( !(iface->i_flags & IFACE_ALLMULTI)) {
                fprintf( newconf, " -noallmulti");
             }
+#endif
 
            fprintf( newconf, " -phase %d",
                    ( iface->i_flags & IFACE_PHASE1 ) ? 1 : 2 );
@@ -259,9 +264,20 @@ int writeconf( cf )
                    ntohs( iface->i_addr.sat_addr.s_net ),
                    iface->i_addr.sat_addr.s_node );
            for ( l = iface->i_rt->rt_zt; l; l = l->l_next ) {
-               fprintf( newconf, " -zone \"%.*s\"",
-                       ((struct ziptab *)l->l_data)->zt_len,
-                       ((struct ziptab *)l->l_data)->zt_name );
+                /* codepage conversion */
+                if ((size_t)(-1) == (len = convert_string_allocate(CH_MAC, CH_UNIX, 
+                                      ((struct ziptab *)l->l_data)->zt_name,
+                                      ((struct ziptab *)l->l_data)->zt_len,
+                                      &zonename)) ) {
+                    if ( NULL == 
+                      (zonename = strdup(((struct ziptab *)l->l_data)->zt_name))) {
+                       LOG(log_error, logtype_atalkd, "malloc: %m" );
+                       return( -1 );
+                    }
+                    len = ((struct ziptab *)l->l_data)->zt_len;
+                } 
+               fprintf( newconf, " -zone \"%.*s\"", (int)len, zonename);
+                free(zonename);
            }
            fprintf( newconf, "\n" );
 
@@ -312,7 +328,7 @@ int readconf( cf )
     struct interface   *iface, *niface;
     char               line[ MAXLINELEN ], **argv, *p;
     unsigned int       i, j;
-    int                        s, cc;
+    int                        s, cc = 0;
     FILE               *conf;
 
     if ( cf == NULL ) {
@@ -342,8 +358,7 @@ int readconf( cf )
         * Check that av[ 0 ] is a valid interface.
         * Not possible under sysV.
         */
-       strncpy( ifr.ifr_name, argv[ 0 ], sizeof(ifr.ifr_name) );
-       ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+       strlcpy( ifr.ifr_name, argv[ 0 ], sizeof(ifr.ifr_name) );
 
        /* for devices that don't support appletalk */
        if ((ioctl(s, SIOCGIFADDR, &ifr) < 0) && (errno == ENODEV)) {
@@ -461,7 +476,7 @@ read_conf_err:
 
 int noallmulti( iface, av )
     struct interface   *iface;
-    char               **av;
+    char               **av _U_;
 {
     /* Linux specific, no effect on other platforms */
     iface->i_flags &= !IFACE_ALLMULTI;
@@ -472,7 +487,7 @@ int noallmulti( iface, av )
 /*ARGSUSED*/
 int router( iface, av )
     struct interface   *iface;
-    char               **av;
+    char               **av _U_;
 {
     /* make sure "-router" and "-dontroute" aren't both on the same line. */
     if (iface->i_flags & IFACE_DONTROUTE) {
@@ -496,7 +511,7 @@ int router( iface, av )
 /*ARGSUSED*/
 int dontroute( iface, av )
     struct interface   *iface;
-    char               **av;
+    char               **av _U_;
 {
     /* make sure "-router" and "-dontroute" aren't both on the same line. */
     if (iface->i_flags & IFACE_RSEED) {
@@ -511,7 +526,7 @@ int dontroute( iface, av )
 /*ARGSUSED*/
 int seed( iface, av )
     struct interface   *iface;
-    char               **av;
+    char               **av _U_;
 {
     /*
      * Check to be sure "-seed" is before "-zone". we keep the old
@@ -668,11 +683,16 @@ int zone( iface, av )
     struct ziptab      *zt;
     char               *zname;
 
-    if (( zname = av[ 0 ] ) == NULL ) {
+    if ( av[ 0 ]  == NULL ) {
        fprintf( stderr, "No zone.\n" );
        return -1;
     }
 
+    /* codepage conversion */
+    if ((size_t)(-1) == convert_string_allocate(CH_UNIX, CH_MAC, av[0], strlen(av[0]), &zname)) {
+       zname = strdup(av[0]);
+    }
+
     /*
      * Only process "-zone" if this interface has "-seed".  We keep our
      * list of configured zones in the interface structure.  Then we can
@@ -683,6 +703,7 @@ int zone( iface, av )
            fprintf( stderr, "Must specify net-range before zones.\n" );
            return -1;
         }
+
        if (( zt = newzt( strlen( zname ), zname )) == NULL ) {
            perror( "newzt" );
            return -1;
@@ -694,6 +715,8 @@ int zone( iface, av )
            iface->i_czt->zt_next = zt;
        }
     }
+    free(zname);
+
     return( 2 );
 }
 
@@ -715,7 +738,7 @@ int getifconf()
 
     start = list = getifacelist();
     while (list && *list) {
-        strncpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
+        strlcpy(ifr.ifr_name, *list, sizeof(ifr.ifr_name));
        list++;
 
        if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
@@ -790,7 +813,7 @@ struct interface *newiface( name )
            == NULL ) {
        return( NULL );
     }
-    strncpy( niface->i_name, name, sizeof(niface->i_name));
+    strlcpy( niface->i_name, name, sizeof(niface->i_name));
 #ifdef BSD4_4
     niface->i_addr.sat_len = sizeof( struct sockaddr_at );
 #endif /* BSD4_4 */