]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
Rework ac/socket.h for HAVE_WINSOCK:
[openldap] / servers / slapd / config.c
index 306b6d9b83cbbbda4c19667efaea74abd585d889..b02313b5cea80a278d19228788c011051459f7c5 100644 (file)
@@ -3,6 +3,9 @@
 #include "portable.h"
 
 #include <stdio.h>
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
 
 #include <ac/string.h>
 #include <ac/ctype.h>
@@ -309,6 +312,35 @@ read_config( char *fname )
                        strcpy( default_referral, "Referral:\n" );
                        strcat( default_referral, cargv[1] );
 
+               /* specify locale */
+               } else if ( strcasecmp( cargv[0], "locale" ) == 0 ) {
+#ifdef HAVE_LOCALE_H
+                       char *locale;
+                       if ( cargc < 2 ) {
+                               Debug( LDAP_DEBUG_ANY,
+       "%s: line %d: missing locale in \"locale <name | on | off>\" line\n",
+                                      fname, lineno, 0 );
+                               return( 1 );
+                       }
+
+                       locale = (strcasecmp(   cargv[1], "on"  ) == 0 ? ""
+                                 : strcasecmp( cargv[1], "off" ) == 0 ? "C"
+                                 : ch_strdup( cargv[1] )                    );
+
+                       if ( setlocale( LC_CTYPE, locale ) == 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                      (*locale
+                                       ? "%s: line %d: bad locale \"%s\"\n"
+                                       : "%s: line %d: bad locale\n"),
+                                      fname, lineno, locale );
+                               return( 1 );
+                       }
+#else
+                       Debug( LDAP_DEBUG_ANY,
+                              "%s: line %d: \"locale\" unsupported\n",
+                              fname, lineno, 0 );
+                       return( 1 );
+#endif
                /* specify an objectclass */
                } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
                        parse_oc( be, fname, lineno, cargc, cargv );
@@ -482,7 +514,7 @@ read_config( char *fname )
                /* pass anything else to the current backend info/db config routine */
                } else {
                        if ( bi != NULL ) {
-                               if (bi->bi_config == NULL) {
+                               if ( bi->bi_config == 0 ) {
                                        Debug( LDAP_DEBUG_ANY,
 "%s: line %d: unknown directive \"%s\" inside backend info definition (ignored)\n",
                                                fname, lineno, cargv[0] );
@@ -494,7 +526,7 @@ read_config( char *fname )
                                        }
                                }
                        } else if ( be != NULL ) {
-                               if ( be->be_config == NULL ) {
+                               if ( be->be_config == 0 ) {
                                        Debug( LDAP_DEBUG_ANY,
 "%s: line %d: unknown directive \"%s\" inside backend database definition (ignored)\n",
                                        fname, lineno, cargv[0] );
@@ -513,6 +545,7 @@ read_config( char *fname )
                }
        }
        fclose( fp );
+       return( 0 );
 }
 
 static int
@@ -570,7 +603,10 @@ strtok_quote( char *line, char *sep )
                        break;
 
                case '\\':
-                       SAFEMEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
+                       if ( next[1] )
+                               SAFEMEMCPY( next,
+                                           next + 1, strlen( next + 1 ) + 1 );
+                       next++;         /* dont parse the escaped character */
                        break;
 
                default:
@@ -622,7 +658,7 @@ fp_getline( FILE *fp, int *lineno )
                if ( (p = strchr( buf, '\n' )) != NULL ) {
                        *p = '\0';
                }
-               if ( ! isspace( buf[0] ) ) {
+               if ( ! isspace( (unsigned char) buf[0] ) ) {
                        return( line );
                }