diff options
| author | Noriko Hosoi <nhosoi@redhat.com> | 2007-06-11 17:22:38 +0000 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2007-06-11 17:22:38 +0000 |
| commit | 3c6758091e1d5bd2eaec52981410d7a01cb2bfa5 (patch) | |
| tree | 32d0bc7b007fb8033cb6c6e721f851ebb545a068 | |
| parent | 941ed15d730bb365a5b056b37c81eccd10ca3c61 (diff) | |
Resolves: #243488
Summary: Use mozldap6 ldif_parse_line API
Changes:
1) Removed ldif.h from the DS tree.
2) Eliminated the 5-th arg of ldif_parse_line (errmsg) and the errmsg related
code.
| -rw-r--r-- | ldap/admin/lib/dsalib_confs.c | 18 | ||||
| -rw-r--r-- | ldap/include/ldif.h | 113 | ||||
| -rw-r--r-- | ldap/servers/plugins/replication/cl5_api.c | 8 | ||||
| -rw-r--r-- | ldap/servers/plugins/replication/replutil.c | 8 | ||||
| -rw-r--r-- | ldap/servers/slapd/back-ldbm/import-threads.c | 7 | ||||
| -rw-r--r-- | ldap/servers/slapd/entry.c | 24 | ||||
| -rw-r--r-- | ldap/servers/slapd/fedse.c | 9 |
7 files changed, 10 insertions, 177 deletions
diff --git a/ldap/admin/lib/dsalib_confs.c b/ldap/admin/lib/dsalib_confs.c index 0a2023ce..bce1594b 100644 --- a/ldap/admin/lib/dsalib_confs.c +++ b/ldap/admin/lib/dsalib_confs.c @@ -78,22 +78,16 @@ ds_get_conf_from_file(FILE *conf) char *type, *value; int vlen = 0; int rc; - char *errmsg = NULL; if ( *line == '\n' || *line == '\0' ) { break; } /* this call modifies line */ - rc = ldif_parse_line(line, &type, &value, &vlen, &errmsg); + rc = ldif_parse_line(line, &type, &value, &vlen); if (rc != 0) { - if ( errmsg != NULL ) { - ds_send_error(errmsg, 0); - PR_smprintf_free(errmsg); - } else { ds_send_error("Unknown error processing config file", 0); - } free(begin); return NULL; } @@ -160,7 +154,7 @@ ds_get_value(char **ds_config, char *parm, int phase, int occurance) * Use ldif_parse_line() so continuation markers are * handled correctly, etc. */ - char *errmsg, *type = NULL, *value = NULL, *tmpvalue = NULL; + char *type = NULL, *value = NULL, *tmpvalue = NULL; int ldif_rc, tmpvlen = 0; char *tmpline = strdup(line); @@ -171,19 +165,15 @@ ds_get_value(char **ds_config, char *parm, int phase, int occurance) return(NULL); } - ldif_rc = ldif_parse_line( tmpline, &type, &tmpvalue, - &tmpvlen, &errmsg ); + ldif_rc = ldif_parse_line( tmpline, &type, &tmpvalue, &tmpvlen ); if (ldif_rc < 0) { - ds_send_error(errmsg, 0 /* do not print errno */); + ds_send_error("Unknown error processing config file", 0); } else if (ldif_rc == 0) { /* value returned in place */ value = strdup(tmpvalue); } else { /* malloc'd value */ value = tmpvalue; } free(tmpline); - if (errmsg) { - PR_smprintf_free(errmsg); - } return value; } } diff --git a/ldap/include/ldif.h b/ldap/include/ldif.h deleted file mode 100644 index c6de212c..00000000 --- a/ldap/include/ldif.h +++ /dev/null @@ -1,113 +0,0 @@ -/** BEGIN COPYRIGHT BLOCK - * This Program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; version 2 of the License. - * - * This Program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - * - * In addition, as a special exception, Red Hat, Inc. gives You the additional - * right to link the code of this Program with code not covered under the GNU - * General Public License ("Non-GPL Code") and to distribute linked combinations - * including the two, subject to the limitations in this paragraph. Non-GPL Code - * permitted under this exception must only link to the code of this Program - * through those well defined interfaces identified in the file named EXCEPTION - * found in the source code files (the "Approved Interfaces"). The files of - * Non-GPL Code may instantiate templates or use macros or inline functions from - * the Approved Interfaces without causing the resulting work to be covered by - * the GNU General Public License. Only Red Hat, Inc. may make changes or - * additions to the list of Approved Interfaces. You must obey the GNU General - * Public License in all respects for all of the Program code and other code used - * in conjunction with the Program except the Non-GPL Code covered by this - * exception. If you modify this file, you may extend this exception to your - * version of the file, but you are not obligated to do so. If you do not wish to - * provide this exception without modification, you must delete this exception - * statement from your version and license this file solely under the GPL without - * exception. - * - * - * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. - * Copyright (C) 2005 Red Hat, Inc. - * All rights reserved. - * END COPYRIGHT BLOCK **/ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -/* - * Copyright (c) 1996 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -#ifndef _LDIF_H -#define _LDIF_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define LDIF_VERSION_ONE 1 /* LDIF standard version */ - -#define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */ - -/* - * Macro to calculate maximum number of bytes that the base64 equivalent - * of an item that is "vlen" bytes long will take up. Base64 encoding - * uses one byte for every six bits in the value plus up to two pad bytes. - */ -#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) - -/* - * Macro to calculate maximum size that an LDIF-encoded type (length - * tlen) and value (length vlen) will take up: room for type + ":: " + - * first newline + base64 value + continued lines. Each continued line - * needs room for a newline and a leading space character. - */ -#define LDIF_SIZE_NEEDED(tlen,vlen) \ - ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ - + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 )) - -/* - * Options for ldif_put_type_and_value_with_options() and - * ldif_type_and_value_with_options(). - */ -#define LDIF_OPT_NOWRAP 0x01UL -#define LDIF_OPT_VALUE_IS_URL 0x02UL -#define LDIF_OPT_MINIMAL_ENCODING 0x04UL - -int ldif_parse_line( char *line, char **type, char **value, int *vlen, char **errcode); -char * ldif_getline( char **next ); -void ldif_put_type_and_value( char **out, char *t, char *val, int vlen ); -void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen ); -void ldif_put_type_and_value_with_options( char **out, char *t, char *val, - int vlen, unsigned long options ); -char *ldif_type_and_value( char *type, char *val, int vlen ); -char *ldif_type_and_value_nowrap( char *type, char *val, int vlen ); -char *ldif_type_and_value_with_options( char *type, char *val, int vlen, - unsigned long options ); -int ldif_base64_decode( char *src, unsigned char *dst ); -int ldif_base64_encode( unsigned char *src, char *dst, int srclen, - int lenused ); -int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen, - int lenused ); -char *ldif_get_entry( FILE *fp, int *lineno ); - - -#ifdef __cplusplus -} -#endif - -#endif /* _LDIF_H */ diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 4c45ec6a..a2bc720b 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -4988,21 +4988,15 @@ _cl5LDIF2Operation (char *ldifEntry, slapi_operation_parameters *op, char **repl next = ldifEntry; while ((line = ldif_getline(&next)) != NULL) { - char *errmsg = NULL; - if ( *line == '\n' || *line == '\0' ) { break; } /* this call modifies ldifEntry */ - rc = ldif_parse_line(line, &type, &value, &vlen, &errmsg); + rc = ldif_parse_line(line, &type, &value, &vlen); if (rc != 0) { - if ( errmsg != NULL ) { - slapi_log_error(SLAPI_LOG_PARSE, repl_plugin_name_cl, "%s", errmsg); - PR_smprintf_free(errmsg ); - } slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5LDIF2Operation: warning - failed to parse ldif line\n"); continue; diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c index c86b14b9..c5e65ee7 100644 --- a/ldap/servers/plugins/replication/replutil.c +++ b/ldap/servers/plugins/replication/replutil.c @@ -428,8 +428,6 @@ parse_changes_string(char *str) slapi_mod_init (&mod, 0); while (line) { - char * errmsg = NULL; - if (strcasecmp (line, "-") == 0) { if (slapi_mod_isvalid (&mod)) @@ -446,14 +444,10 @@ parse_changes_string(char *str) break; } - rc = ldif_parse_line(line, &type, &value, &vlen, &errmsg); + rc = ldif_parse_line(line, &type, &value, &vlen); if (rc != 0) { /* ONREPL - log warning */ - if ( errmsg != NULL ) { - slapi_log_error( SLAPI_LOG_PARSE, repl_plugin_name, "%s", errmsg ); - PR_smprintf_free(errmsg ); - } slapi_log_error( SLAPI_LOG_REPL, repl_plugin_name, "Failed to parse the ldif line.\n"); continue; diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index 6d51a3b0..aab8b9a3 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -283,21 +283,16 @@ import_get_version(char *str) offset = s - str; mystr = ms = slapi_ch_strdup(str); while ( (s = ldif_getline( &ms )) != NULL ) { - char *errmsg = NULL; - if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen, &errmsg )) >= 0 ) { + if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen )) >= 0 ) { if (!strcasecmp(type, "version")) { my_version = atoi(valuecharptr); *(str + offset) = '#'; /* the memory below was not allocated by the slapi_ch_ functions */ - if (errmsg) PR_smprintf_free(errmsg); if (retmalloc) slapi_ch_free((void **) &valuecharptr); break; } - } else if ( errmsg != NULL ) { - LDAPDebug( LDAP_DEBUG_PARSE, "%s", errmsg, 0, 0 ); } /* the memory below was not allocated by the slapi_ch_ functions */ - if (errmsg) slapi_ch_free((void **) &errmsg); if (retmalloc) slapi_ch_free((void **) &valuecharptr); } diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 0ae4b4fb..31e2cb08 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -203,27 +203,17 @@ str2entry_fast( char *s, int flags, int read_stateinfo ) int maxvals; int del_maxvals; char *type; - char *errmsg = NULL; if ( *s == '\n' || *s == '\0' ) { break; } - if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen, &errmsg )) < 0 ) { - if ( errmsg != NULL ) { - LDAPDebug( LDAP_DEBUG_PARSE, "%s", errmsg, 0, 0 ); - /* the memory below was not allocated by the slapi_ch_ functions */ - PR_smprintf_free(errmsg ); - } + if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen )) < 0 ) { LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast NULL (parse_line)\n", 0, 0, 0 ); continue; } - /* We don't use errmsg anywhere later. free it to avoid leaking... */ - /* the memory below was not allocated by the slapi_ch_ functions */ - slapi_ch_free( (void**)&errmsg ); - /* * Extract the attribute and value CSNs from the attribute type. */ @@ -581,7 +571,6 @@ str2entry_dupcheck( char *s, int flags, int read_stateinfo ) int i, j; char *next=NULL; char *valuecharptr=NULL; - char *errmsg = NULL; int retmalloc = 0; int rc; int fast_dup_check = 0; @@ -617,21 +606,12 @@ str2entry_dupcheck( char *s, int flags, int read_stateinfo ) break; } - if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen, &errmsg )) < 0 ) { - if ( errmsg != NULL ) { - LDAPDebug( LDAP_DEBUG_PARSE, "%s", errmsg, 0, 0 ); - /* the memory below was not allocated by the slapi_ch_ functions */ - PR_smprintf_free(errmsg ); - } + if ( (retmalloc = ldif_parse_line( s, &type, &valuecharptr, &valuelen )) < 0 ) { LDAPDebug( LDAP_DEBUG_TRACE, "<= slapi_str2entry NULL (parse_line)\n", 0, 0, 0 ); continue; } - /* We don't use errmsg anywhere later. free it to avoid leaking... */ - /* the memory below was not allocated by the slapi_ch_ functions */ - slapi_ch_free( (void**)&errmsg ); - /* * Extract the attribute and value CSNs from the attribute type. */ diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c index 0b07a97c..f71b7fdd 100644 --- a/ldap/servers/slapd/fedse.c +++ b/ldap/servers/slapd/fedse.c @@ -1735,7 +1735,6 @@ search_easter_egg( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entr { static int twiddle= -1; char *type, *value, *copy; - char *errmsg = NULL; int vlen; struct berval bv; struct berval *bvals[2]; @@ -1745,12 +1744,7 @@ search_easter_egg( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entr bvals[0] = &bv; bvals[1] = NULL; copy= slapi_ch_strdup(easter_egg_photos[twiddle%NUM_EASTER_EGG_PHOTOS]); - if ( (retmalloc = ldif_parse_line(copy, &type, &value, &vlen, &errmsg)) < 0 ) { - if ( errmsg != NULL ) { - slapi_log_error( SLAPI_LOG_PARSE, "dse", "%s", errmsg ); - /* the memory below was not allocated by the slapi_ch_ functions */ - PR_smprintf_free(errmsg ); - } + if ( (retmalloc = ldif_parse_line(copy, &type, &value, &vlen)) < 0 ) { return SLAPI_DSE_CALLBACK_ERROR; } bv.bv_val = value; @@ -1760,7 +1754,6 @@ search_easter_egg( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entr slapi_ch_free((void**)©); twiddle++; /* the memory below was not allocated by the slapi_ch_ functions */ - slapi_ch_free( (void**)&errmsg ); if (retmalloc) slapi_ch_free( (void**)&value ); return SLAPI_DSE_CALLBACK_OK; } |
