You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by sterling <st...@covalent.net> on 2001/03/13 23:30:10 UTC

[PATCH] add ap_set_int_slot

Hi -

I think this has been suggested/submitted before, but it would be
useful to commit some kind of ap_set_int_slot to the tree.  included is a
patch that does it.  note that this patch doesn't raise an error when
underflow/overflow happens - if you think we should add that support it
would be easy.

sterling


Index: include/http_config.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/http_config.h,v
retrieving revision 1.71
diff -u -r1.71 http_config.h
--- include/http_config.h	2001/02/25 01:12:50	1.71
+++ include/http_config.h	2001/03/13 22:19:33
@@ -483,6 +483,18 @@
 						   const char *arg);
 
 /**
+ * Generic command handling function for integers
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return An error string or NULL on success
+ * @deffunc const char *ap_set_int_slot(cmd_parms *cmd, void *struct_ptr, const char *arg)
+ */
+AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, 
+                                                void *struct_ptr,
+                                                const char *arg);
+
+/**
  * Return true if the specified method is limited by being listed in
  * a <Limit> container, or by *not* being listed in a <LimiteExcept>
  * container.
Index: server/config.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/config.c,v
retrieving revision 1.119
diff -u -r1.119 config.c
--- server/config.c	2001/03/06 21:46:12	1.119
+++ server/config.c	2001/03/13 22:19:36
@@ -1055,6 +1055,22 @@
     return NULL;
 }
 
+AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
+                                                void *struct_ptr,
+                                                const char *arg)
+{
+    char *endptr;
+    char *error_str = NULL;
+    int offset = (int) (long) cmd->info;
+    *(int *) (struct_ptr + offset) = strtol(arg, &endptr, 10);
+    if( (*arg == '\0') || (*endptr != '\0') ) {
+        error_str = apr_psprintf(cmd->pool, 
+                     "Invalid value for directive %s, expected integer",
+                     cmd->directive->directive);
+    }
+    return error_str;
+}
+
 AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
 							 void *struct_ptr,
 							 const char *arg_)