static unsigned short *_ucprop_offsets;
static unsigned long *_ucprop_ranges;
-static void
+/*
+ * Return -1 on error, 0 if okay
+ */
+static int
_ucprop_load(char *paths, int reload)
{
FILE *in;
/*
* The character properties have already been loaded.
*/
- return;
+ return 0;
/*
* Unload the current character property data in preparation for
}
if ((in = _ucopenfile(paths, "ctype.dat", "rb")) == 0)
- return;
+ return -1;
/*
* Load the header.
if ((_ucprop_size = hdr.cnt) == 0) {
fclose(in);
- return;
+ return -1;
}
/*
for (i = 0; i < _ucprop_offsets[_ucprop_size]; i++)
_ucprop_ranges[i] = endian_long(_ucprop_ranges[i]);
}
+ return 0;
}
static void
static unsigned short _uccase_len[2];
static unsigned long *_uccase_map;
-static void
+/*
+ * Return -1 on error, 0 if okay
+ */
+static int
_uccase_load(char *paths, int reload)
{
FILE *in;
/*
* The case mappings have already been loaded.
*/
- return;
+ return 0;
free((char *) _uccase_map);
_uccase_size = 0;
}
if ((in = _ucopenfile(paths, "case.dat", "rb")) == 0)
- return;
+ return -1;
/*
* Load the header.
for (i = 0; i < _uccase_size; i++)
_uccase_map[i] = endian_long(_uccase_map[i]);
}
+ return 0;
}
static void
static unsigned long *_ucdcmp_nodes;
static unsigned long *_ucdcmp_decomp;
-static void
+/*
+ * Return -1 on error, 0 if okay
+ */
+static int
_ucdcmp_load(char *paths, int reload)
{
FILE *in;
/*
* The decompositions have already been loaded.
*/
- return;
+ return 0;
free((char *) _ucdcmp_nodes);
_ucdcmp_size = 0;
}
if ((in = _ucopenfile(paths, "decomp.dat", "rb")) == 0)
- return;
+ return -1;
/*
* Load the header.
if (hdr.bom == 0xfffe) {
for (i = 0; i < size; i++)
_ucdcmp_nodes[i] = endian_long(_ucdcmp_nodes[i]);
- }
+ }
+ return 0;
}
static void
static unsigned long _uccmcl_size;
static unsigned long *_uccmcl_nodes;
-static void
+/*
+ * Return -1 on error, 0 if okay
+ */
+static int
_uccmcl_load(char *paths, int reload)
{
FILE *in;
/*
* The combining classes have already been loaded.
*/
- return;
+ return 0;
free((char *) _uccmcl_nodes);
_uccmcl_size = 0;
}
if ((in = _ucopenfile(paths, "cmbcl.dat", "rb")) == 0)
- return;
+ return -1;
/*
* Load the header.
if (hdr.bom == 0xfffe) {
for (i = 0; i < _uccmcl_size; i++)
_uccmcl_nodes[i] = endian_long(_uccmcl_nodes[i]);
- }
+ }
+ return 0;
}
static void
static unsigned long _ucnum_size;
static short *_ucnum_vals;
-void
+/*
+ * Return -1 on error, 0 if okay
+ */
+static int
_ucnumb_load(char *paths, int reload)
{
FILE *in;
/*
* The numbers have already been loaded.
*/
- return;
+ return 0;
free((char *) _ucnum_nodes);
_ucnum_size = 0;
}
if ((in = _ucopenfile(paths, "num.dat", "rb")) == 0)
- return;
+ return -1;
/*
* Load the header.
for (i = 0; i < size; i++)
_ucnum_vals[i] = endian_short(_ucnum_vals[i]);
- }
+ }
+ return 0;
}
static void
*
**************************************************************************/
-void
+/*
+ * Return 0 if okay, negative on error
+ */
+int
ucdata_load(char *paths, int masks)
{
+ int error = 0;
if (masks & UCDATA_CTYPE)
- _ucprop_load(paths, 0);
+ error |= _ucprop_load(paths, 0) < 0 ? UCDATA_CTYPE : 0;
if (masks & UCDATA_CASE)
- _uccase_load(paths, 0);
+ error |= _uccase_load(paths, 0) < 0 ? UCDATA_CASE : 0;
if (masks & UCDATA_DECOMP)
- _ucdcmp_load(paths, 0);
+ error |= _ucdcmp_load(paths, 0) < 0 ? UCDATA_DECOMP : 0;
if (masks & UCDATA_CMBCL)
- _uccmcl_load(paths, 0);
+ error |= _uccmcl_load(paths, 0) < 0 ? UCDATA_CMBCL : 0;
if (masks & UCDATA_NUM)
- _ucnumb_load(paths, 0);
+ error |= _ucnumb_load(paths, 0) < 0 ? UCDATA_NUM : 0;
+ return -error;
}
void
_ucnumb_unload();
}
-void
+/*
+ * Return 0 if okay, negative on error
+ */
+int
ucdata_reload(char *paths, int masks)
{
+ int error = 0;
if (masks & UCDATA_CTYPE)
- _ucprop_load(paths, 1);
+ error |= _ucprop_load(paths, 1) < 0 ? UCDATA_CTYPE : 0;
if (masks & UCDATA_CASE)
- _uccase_load(paths, 1);
+ error |= _uccase_load(paths, 1) < 0 ? UCDATA_CASE : 0;
if (masks & UCDATA_DECOMP)
- _ucdcmp_load(paths, 1);
+ error |= _ucdcmp_load(paths, 1) < 0 ? UCDATA_DECOMP : 0;
if (masks & UCDATA_CMBCL)
- _uccmcl_load(paths, 1);
+ error |= _uccmcl_load(paths, 1) < 0 ? UCDATA_CMBCL : 0;
if (masks & UCDATA_NUM)
- _ucnumb_load(paths, 1);
+ error |= _ucnumb_load(paths, 1) < 0 ? UCDATA_NUM : 0;
+ return -error;
}
#ifdef TEST
default_search_base = ch_strdup( cargv[1] );
default_search_nbase = ch_strdup( cargv[1] );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
if( dn_normalize( default_search_nbase ) == NULL ) {
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"invalid default search base \"%s\"\n",
/* set UCDATA path */
} else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
+ int err;
if ( cargc < 2 ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: missing path in \"ucdata-path <path>\" line\n",
return( 1 );
}
- if ( load_ucdata( cargv[1] ) == 0 ) {
- Debug( LDAP_DEBUG_ANY,
- "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
- fname, lineno, 0 );
- return 1;
+ err = load_ucdata( cargv[1] );
+ if ( err <= 0 ) {
+ if ( err == 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: ucdata already loaded, ucdata-path must be set earlier in the file and/or be specified only once!\n",
+ fname, lineno, 0 );
+ }
+ return( 1 );
}
/* set time limit */
fname, lineno, tmp_be->be_suffix[0] );
} else {
char *dn = ch_strdup( cargv[1] );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
if( dn_validate( dn ) == NULL ) {
Debug( LDAP_DEBUG_ANY, "%s: line %d: "
"suffix DN invalid \"%s\"\n",
char *alias, *aliased_dn;
alias = ch_strdup( cargv[1] );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
(void) dn_normalize( alias );
aliased_dn = ch_strdup( cargv[2] );
be->be_root_dn = ch_strdup( cargv[1] );
be->be_root_ndn = ch_strdup( cargv[1] );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
if( dn_normalize( be->be_root_ndn ) == NULL ) {
free( be->be_root_dn );
free( be->be_root_ndn );
fname, lineno, 0 );
} else {
be->be_update_ndn = ch_strdup( cargv[1] );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
if( dn_normalize( be->be_update_ndn ) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: updatedn DN is invalid\n",
free( saveline );
}
fclose( fp );
- load_ucdata( NULL );
+ if ( load_ucdata( NULL ) < 0 ) {
+ return( 1 );
+ }
return( 0 );
}
buf[0] = '\0';
}
-/* Loads ucdata, returns 1 if loading, 0 if already loaded */
+/* Loads ucdata, returns 1 if loading, 0 if already loaded, -1 on error */
static int
load_ucdata( char *path )
{
static int loaded = 0;
-
+ int err;
+
if ( loaded ) {
- return 0;
+ return( 0 );
+ }
+ err = ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
+ UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
+ if ( err ) {
+ Debug( LDAP_DEBUG_ANY, "error loading ucdata (error %d)\n",
+ err, 0, 0 );
+ return( -1 );
}
- ucdata_load( path ? path : SLAPD_DEFAULT_UCDATA,
- UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
loaded = 1;
- return 1;
+ return( 1 );
}