From 671e3c7651680843067d8a2185587a9a4fba4e08 Mon Sep 17 00:00:00 2001
From: Pierangelo Masarati <ando@openldap.org>
Date: Fri, 18 Jun 2004 19:47:53 +0000
Subject: [PATCH] allow max for time/size limits

---
 clients/tools/ldapsearch.c | 18 ++++++++++++++++--
 doc/man/man1/ldapsearch.1  |  6 ++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c
index e577736b6e..071da08047 100644
--- a/clients/tools/ldapsearch.c
+++ b/clients/tools/ldapsearch.c
@@ -116,7 +116,7 @@ usage( void )
 	fprintf( stderr, _("             [!]sync=ro[/<cookie>]            (LDAP Sync refreshOnly)\n"));
 	fprintf( stderr, _("                     rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)\n"));
 	fprintf( stderr, _("  -F prefix  URL prefix for files (default: %s)\n"), def_urlpre);
-	fprintf( stderr, _("  -l limit   time limit (in seconds) for search\n"));
+	fprintf( stderr, _("  -l limit   time limit (in seconds, or \"none\" or \"max\") for search\n"));
 	fprintf( stderr, _("  -L         print responses in LDIFv1 format\n"));
 	fprintf( stderr, _("  -LL        print responses in LDIF format without comments\n"));
 	fprintf( stderr, _("  -LLL       print responses in LDIF format without comments\n"));
@@ -127,7 +127,7 @@ usage( void )
 	fprintf( stderr, _("  -tt        write all values to files in temporary directory\n"));
 	fprintf( stderr, _("  -T path    write files to directory specified by path (default: %s)\n"), def_tmpdir);
 	fprintf( stderr, _("  -u         include User Friendly entry names in the output\n"));
-	fprintf( stderr, _("  -z limit   size limit (in entries) for search\n"));
+	fprintf( stderr, _("  -z limit   size limit (in entries, or \"none\" or \"max\") for search\n"));
 	tool_common_usage();
 	exit( EXIT_FAILURE );
 }
@@ -436,6 +436,13 @@ handle_private_option( int i )
 	case 'l':	/* time limit */
 		if ( strcasecmp( optarg, "none" ) == 0 ) {
 			timelimit = 0;
+
+		} else if ( strcasecmp( optarg, "max" ) == 0 ) {
+			/* RFC 2251:
+			        maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
+			 */
+			timelimit = 2147483647;
+
 		} else {
 			ival = strtol( optarg, &next, 10 );
 			if ( next == NULL || next[0] != '\0' ) {
@@ -487,6 +494,13 @@ handle_private_option( int i )
 	case 'z':	/* size limit */
 		if ( strcasecmp( optarg, "none" ) == 0 ) {
 			sizelimit = 0;
+
+		} else if ( strcasecmp( optarg, "max" ) == 0 ) {
+			/* RFC 2251:
+			        maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
+			 */
+			sizelimit = 2147483647;
+
 		} else {
 			ival = strtol( optarg, &next, 10 );
 			if ( next == NULL || next[0] != '\0' ) {
diff --git a/doc/man/man1/ldapsearch.1 b/doc/man/man1/ldapsearch.1
index ebc918cb5f..3f44bc3fdb 100644
--- a/doc/man/man1/ldapsearch.1
+++ b/doc/man/man1/ldapsearch.1
@@ -227,6 +227,9 @@ A timelimit of
 (zero) or
 .I none
 means no limit.
+A timelimit of
+.I max
+means the maximum integer allowable by the protocol.
 A server may impose a maximal timelimit which only
 the root user may override.
 .TP
@@ -237,6 +240,9 @@ A sizelimit of
 (zero) or
 .I none
 means no limit.
+A sizelimit of
+.I max
+means the maximum integer allowable by the protocol.
 A server may impose a maximal sizelimit which only
 the root user may override.
 .TP
-- 
GitLab