]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/shell-backends/shellutil.c
filter2bv can't de-normalize UUIDs, must do it explicitly for back-ldap
[openldap] / servers / slapd / shell-backends / shellutil.c
index 1bbf55abcd52e2ccaa8f096a23b44ab2355b6154..0321061bd4c62970b2d494bbe67d7e66a39a7bb8 100644 (file)
@@ -1,17 +1,32 @@
-/*
- shellutil.c - common routines useful when building shell-based backends
-                for the standalone ldap server
-
- Copyright (c) 1995 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.
-*/
+/* shellutil.c - common routines useful when building shell-based backends */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright (c) 1995 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.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
+ */
 
 
 #include "portable.h"
@@ -88,7 +103,8 @@ write_entry( struct ldop *op, struct ldentry *entry, FILE *ofp )
 int
 test_filter( struct ldop *op, struct ldentry *entry )
 {
-    return (( random() & 0x07 ) == 0x07 );     /* XXX random for now */
+    return ((random() & 0x07 ) == 0x07) /* XXX random for now */
+               ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE;
 }
 
 
@@ -139,7 +155,7 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op )
     struct inputparams *ip;
 
     if ( fgets( line, MAXLINELEN, ifp ) == NULL ) {
-       write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Empty Input" );
+       write_result( ofp, LDAP_OTHER, NULL, "Empty Input" );
     }
     line[ strlen( line ) - 1 ] = '\0';
     if ( strncasecmp( line, STR_OP_SEARCH, sizeof( STR_OP_SEARCH ) - 1 )
@@ -169,21 +185,32 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op )
            op->ldop_dn = estrdup( args );
            break;
        case IP_TYPE_SCOPE:
-           if (( op->ldop_srch.ldsp_scope = atoi( args )) != LDAP_SCOPE_BASE &&
+           if ( lutil_atoi( &op->ldop_srch.ldsp_scope, args ) != 0 ||
+               ( op->ldop_srch.ldsp_scope != LDAP_SCOPE_BASE &&
                    op->ldop_srch.ldsp_scope != LDAP_SCOPE_ONELEVEL &&
-                   op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) {
-               write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Bad scope" );
+                   op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) )
+           {
+               write_result( ofp, LDAP_OTHER, NULL, "Bad scope" );
                return( -1 );
            }
            break;
        case IP_TYPE_ALIASDEREF:
-           op->ldop_srch.ldsp_aliasderef = atoi( args );
+           if ( lutil_atoi( &op->ldop_srch.ldsp_aliasderef, args ) != 0 ) {
+               write_result( ofp, LDAP_OTHER, NULL, "Bad alias deref" );
+               return( -1 );
+           }
            break;
        case IP_TYPE_SIZELIMIT:
-           op->ldop_srch.ldsp_sizelimit = atoi( args );
+           if ( lutil_atoi( &op->ldop_srch.ldsp_sizelimit, args ) != 0 ) {
+               write_result( ofp, LDAP_OTHER, NULL, "Bad size limit" );
+               return( -1 );
+           }
            break;
        case IP_TYPE_TIMELIMIT:
-           op->ldop_srch.ldsp_timelimit = atoi( args );
+           if ( lutil_atoi( &op->ldop_srch.ldsp_timelimit, args ) != 0 ) {
+               write_result( ofp, LDAP_OTHER, NULL, "Bad time limit" );
+               return( -1 );
+           }
            break;
        case IP_TYPE_FILTER:
            op->ldop_srch.ldsp_filter = estrdup( args );
@@ -212,7 +239,7 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op )
 
     if ( op->ldop_suffixes == NULL || op->ldop_dn == NULL ||
                op->ldop_srch.ldsp_filter == NULL ) {
-       write_result( ofp, LDAP_OPERATIONS_ERROR, NULL,
+       write_result( ofp, LDAP_OTHER, NULL,
                "Required suffix:, base:, or filter: missing" );
        return( -1 );
     }