* @param methname The name of the new method to register.
* @return Ab int value representing an offset into a bitmask.
*/
-AP_DECLARE(int) ap_method_register(apr_pool_t *p, char *methname);
+AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);
/**
* Initialize the method_registry and allocate memory for it.
* This is a convenience macro to ease with checking a mask
* against a method name.
*/
-#define AP_METHOD_CHECK_ALLOWED(mask, methname) ((mask) & (1 << ap_method_number_of((methname))))
+#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
+ ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))
/**
* Create a new method list with the specified number of preallocated
*/
#define METHODS 64
+/**
+ * The method mask bit to shift for anding with a bitmask.
+ */
+#define AP_METHOD_BIT (apr_int64_t)1
+
+
typedef struct ap_method_list_t ap_method_list_t;
/**
* Structure for handling HTTP methods. Methods known to the server are
return "unknown order";
for (i = 0; i < METHODS; ++i)
- if (cmd->limited & (1 << i))
+ if (cmd->limited & (AP_METHOD_BIT << i))
d->order[i] = o;
return NULL;
{
allowdeny *ap = (allowdeny *) a->elts;
- apr_int64_t mmask = (1 << method);
+ apr_int64_t mmask = (AP_METHOD_BIT << method);
int i;
int gothost = 0;
const char *remotehost = NULL;
for (x = 0; x < reqs_arr->nelts; x++) {
- if (!(reqs[x].method_mask & (1 << m)))
+ if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
continue;
method_restricted = 1;
for (x = 0; x < reqs_arr->nelts; x++) {
- if (!(reqs[x].method_mask & (1 << m)))
+ if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
continue;
t = reqs[x].requirement;
for (x = 0; x < reqs_arr->nelts; x++) {
- if (!(reqs[x].method_mask & (1 << m)))
+ if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
continue;
t = reqs[x].requirement;
for (x = 0; x < reqs_arr->nelts; x++) {
- if (!(reqs[x].method_mask & (1 << m)))
+ if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
continue;
method_restricted = 1;
}
/* note that we would handle GET on this resource */
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
/* This handler has no use for a request body (yet), but we still
* need to read and discard it if the client sent one.
* These are the HTTP-defined methods that we handle directly.
*/
r->allowed = 0
- | (1 << M_GET)
- | (1 << M_PUT)
- | (1 << M_DELETE)
- | (1 << M_OPTIONS)
- | (1 << M_INVALID);
+ | (AP_METHOD_BIT << M_GET)
+ | (AP_METHOD_BIT << M_PUT)
+ | (AP_METHOD_BIT << M_DELETE)
+ | (AP_METHOD_BIT << M_OPTIONS)
+ | (AP_METHOD_BIT << M_INVALID);
/*
* These are the DAV methods we handle.
*/
r->allowed |= 0
- | (1 << M_COPY)
- | (1 << M_LOCK)
- | (1 << M_UNLOCK)
- | (1 << M_MKCOL)
- | (1 << M_MOVE)
- | (1 << M_PROPFIND)
- | (1 << M_PROPPATCH);
+ | (AP_METHOD_BIT << M_COPY)
+ | (AP_METHOD_BIT << M_LOCK)
+ | (AP_METHOD_BIT << M_UNLOCK)
+ | (AP_METHOD_BIT << M_MKCOL)
+ | (AP_METHOD_BIT << M_MOVE)
+ | (AP_METHOD_BIT << M_PROPFIND)
+ | (AP_METHOD_BIT << M_PROPPATCH);
/*
* These are methods that we don't handle directly, but let the
* server's default handler do for us as our agent.
*/
r->allowed |= 0
- | (1 << M_POST);
+ | (AP_METHOD_BIT << M_POST);
/* ### hrm. if we return HTTP_METHOD_NOT_ALLOWED, then an Allow header
* ### is sent; it will need the other allowed states; since the default
if (!(ap_allow_options(r) & OPT_INCLUDES)) {
return ap_pass_brigade(f->next, b);
}
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET) {
return ap_pass_brigade(f->next, b);
}
if(strcmp(r->handler,ASIS_MAGIC_TYPE) && strcmp(r->handler,"send-as-is"))
return DECLINED;
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET)
return DECLINED;
if (r->finfo.filetype == 0) {
d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
&autoindex_module);
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET) {
return DECLINED;
}
if (r->method_number == M_OPTIONS) {
/* 99 out of 100 CGI scripts, this is all they support */
- r->allowed |= (1 << M_GET);
- r->allowed |= (1 << M_POST);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_POST);
return DECLINED;
}
if (r->method_number == M_OPTIONS) {
/* 99 out of 100 cgid scripts, this is all they support */
- r->allowed |= (1 << M_GET);
- r->allowed |= (1 << M_POST);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_POST);
return DECLINED;
}
if (strcmp(r->handler, "server-info"))
return DECLINED;
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET)
return DECLINED;
"Server status unavailable in inetd mode");
return HTTP_INTERNAL_SERVER_ERROR;
}
- r->allowed = (1 << M_GET);
+ r->allowed = (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET)
return DECLINED;
apr_pool_cleanup_null);
}
-AP_DECLARE(int) ap_method_register(apr_pool_t *p, char *methname)
+AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname)
{
int *newmethnum;
mask = r->allowed_methods->method_mask;
list = apr_pstrcat(r->pool,
- (mask & (1 << M_GET)) ? ", GET, HEAD" : "",
- (mask & (1 << M_POST)) ? ", POST" : "",
- (mask & (1 << M_PUT)) ? ", PUT" : "",
- (mask & (1 << M_DELETE)) ? ", DELETE" : "",
- (mask & (1 << M_CONNECT)) ? ", CONNECT" : "",
- (mask & (1 << M_OPTIONS)) ? ", OPTIONS" : "",
- (mask & (1 << M_PATCH)) ? ", PATCH" : "",
- (mask & (1 << M_PROPFIND)) ? ", PROPFIND" : "",
- (mask & (1 << M_PROPPATCH)) ? ", PROPPATCH" : "",
- (mask & (1 << M_MKCOL)) ? ", MKCOL" : "",
- (mask & (1 << M_COPY)) ? ", COPY" : "",
- (mask & (1 << M_MOVE)) ? ", MOVE" : "",
- (mask & (1 << M_LOCK)) ? ", LOCK" : "",
- (mask & (1 << M_UNLOCK)) ? ", UNLOCK" : "",
+ (mask & (AP_METHOD_BIT << M_GET)) ? ", GET, HEAD" : "",
+ (mask & (AP_METHOD_BIT << M_POST)) ? ", POST" : "",
+ (mask & (AP_METHOD_BIT << M_PUT)) ? ", PUT" : "",
+ (mask & (AP_METHOD_BIT << M_DELETE)) ? ", DELETE" : "",
+ (mask & (AP_METHOD_BIT << M_CONNECT)) ? ", CONNECT" : "",
+ (mask & (AP_METHOD_BIT << M_OPTIONS)) ? ", OPTIONS" : "",
+ (mask & (AP_METHOD_BIT << M_PATCH)) ? ", PATCH" : "",
+ (mask & (AP_METHOD_BIT << M_PROPFIND)) ? ", PROPFIND" : "",
+ (mask & (AP_METHOD_BIT << M_PROPPATCH)) ? ", PROPPATCH" : "",
+ (mask & (AP_METHOD_BIT << M_MKCOL)) ? ", MKCOL" : "",
+ (mask & (AP_METHOD_BIT << M_COPY)) ? ", COPY" : "",
+ (mask & (AP_METHOD_BIT << M_MOVE)) ? ", MOVE" : "",
+ (mask & (AP_METHOD_BIT << M_LOCK)) ? ", LOCK" : "",
+ (mask & (AP_METHOD_BIT << M_UNLOCK)) ? ", UNLOCK" : "",
", TRACE",
NULL);
- if ((mask & (1 << M_INVALID))
+ if ((mask & (AP_METHOD_BIT << M_INVALID))
&& (r->allowed_methods->method_list != NULL)
&& (r->allowed_methods->method_list->nelts != 0)) {
int i;
*/
methnum = ap_method_number_of(method);
if (methnum != M_INVALID) {
- return !!(l->method_mask & (1 << methnum));
+ return !!(l->method_mask & (AP_METHOD_BIT << methnum));
}
/*
* Otherwise, see if the method name is in the array or string names
* bitmask.
*/
methnum = ap_method_number_of(method);
- l->method_mask |= (1 << methnum);
+ l->method_mask |= (AP_METHOD_BIT << methnum);
if (methnum != M_INVALID) {
return;
}
* by a module, use the bitmask.
*/
methnum = ap_method_number_of(method);
- l->method_mask |= ~(1 << methnum);
+ l->method_mask |= ~(AP_METHOD_BIT << methnum);
if (methnum != M_INVALID) {
return;
}
/* Set allowed stuff */
for (i = 0; i < METHODS; ++i) {
if (conf->scripted[i])
- r->allowed |= (1 << i);
+ r->allowed |= (AP_METHOD_BIT << i);
}
/* First, check for the method-handling scripts */
d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
&autoindex_module);
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET) {
return DECLINED;
}
char buf[MAX_SEGMENT + 1];
unsigned int len;
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET)
return DECLINED;
unsigned total_failures;
int i;
- r->allowed |= (1 << M_GET);
+ r->allowed |= (AP_METHOD_BIT << M_GET);
if (r->method_number != M_GET)
return DECLINED;
* added by a module and registered.
*/
if (methnum != M_INVALID) {
- return !!(cmd->limited & (1<<methnum));
+ return !!(cmd->limited & (AP_METHOD_BIT << methnum));
}
return 0; /* not found */
*/
methnum = ap_method_register(cmd->pool, method);
}
- limited |= (1 << methnum);
+ limited |= (AP_METHOD_BIT << methnum);
}
/* Killing two features with one function,
reqs = (require_line *) reqs_arr->elts;
for (i = 0; i < reqs_arr->nelts; ++i)
- if (reqs[i].method_mask & (1 << r->method_number))
+ if (reqs[i].method_mask & (AP_METHOD_BIT << r->method_number))
return 1;
return 0;