You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2002/09/16 01:45:35 UTC

cvs commit: httpd-python/src/include util.h

grisha      2002/09/15 16:45:35

  Modified:    src      requestobject.c util.c
               src/include util.h
  Log:
  Fixed a bug where we were trying to add an offset to a pointer without
  having it cast to void* first. Also got rid of some mentions of memberlist
  in favor of PyMemberDef.
  
  Revision  Changes    Path
  1.31      +13 -12    httpd-python/src/requestobject.c
  
  Index: requestobject.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/requestobject.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- requestobject.c	12 Sep 2002 18:24:06 -0000	1.30
  +++ requestobject.c	15 Sep 2002 23:45:35 -0000	1.31
  @@ -861,7 +861,7 @@
   
   #define OFF(x) offsetof(request_rec, x)
   
  -static struct memberlist request_rec_mbrs[] = {
  +static struct PyMemberDef request_rec_mbrs[] = {
       {"the_request",        T_STRING,  OFF(the_request)},
       {"assbackwards",       T_INT,     OFF(assbackwards)},
       {"proxyreq",           T_INT,     OFF(proxyreq)},
  @@ -919,8 +919,8 @@
   
   static PyObject *getreq_recmbr(requestobject *self, void *name) 
   {
  -    return PyMember_Get((char*)self->request_rec, request_rec_mbrs, 
  -                        (char*)name);
  +    return PyMember_GetOne((char*)self->request_rec,
  +                           find_memberdef(request_rec_mbrs, name));
   }
   
   /**
  @@ -931,6 +931,7 @@
   
   static int setreq_recmbr(requestobject *self, PyObject *val, void *name) 
   {
  +
       if (strcmp(name, "content_type") == 0) {
           if (! PyString_Check(val)) {
               PyErr_SetString(PyExc_TypeError, "content_type must be a string");
  @@ -960,8 +961,9 @@
           return 0;
       }
       
  -    return PyMember_Set((char*)self->request_rec, request_rec_mbrs, 
  -                        (char*)name, val);
  +    return PyMember_SetOne((char*)self->request_rec, 
  +                           find_memberdef(request_rec_mbrs, (char*)name),
  +                           val);
   }
   
   /**
  @@ -974,7 +976,7 @@
   {
       const PyMemberDef *md = find_memberdef(request_rec_mbrs, (char*)name);
       apr_array_header_t *ah = 
  -        (apr_array_header_t *)(self->request_rec + md->offset);
  +        (apr_array_header_t *)((void *)self->request_rec + md->offset);
   
       return tuple_from_array_header(ah);
   }
  @@ -989,7 +991,7 @@
   {
       const PyMemberDef *md = find_memberdef(request_rec_mbrs, (char*)name);
       ap_method_list_t *ml = 
  -        (ap_method_list_t *)(self->request_rec + md->offset);
  +        (ap_method_list_t *)((void *)self->request_rec + md->offset);
   
       return tuple_from_method_list(ml);
   }
  @@ -1004,7 +1006,7 @@
   {
       const PyMemberDef *md = find_memberdef(request_rec_mbrs, (char*)name);
       apr_finfo_t *fi = 
  -        (apr_finfo_t *)(self->request_rec + md->offset);
  +        (apr_finfo_t *)((void *)self->request_rec + md->offset);
   
       return tuple_from_finfo(fi);
   }
  @@ -1018,8 +1020,7 @@
   static PyObject *getreq_rec_uri(requestobject *self, void *name) 
   {
       const PyMemberDef *md = find_memberdef(request_rec_mbrs, (char*)name);
  -    apr_uri_t *uri = 
  -        (apr_uri_t *)(self->request_rec + md->offset);
  +    apr_uri_t *uri = (apr_uri_t *)((void *)self->request_rec + md->offset);
   
       return tuple_from_apr_uri(uri);
   }
  @@ -1073,7 +1074,7 @@
       {"path_info",     (getter)getreq_recmbr, NULL, "Path_info, if any", "path_info"},
       {"args",          (getter)getreq_recmbr, NULL, "QUERY_ARGS, if any", "args"},
       {"finfo",         (getter)getreq_rec_fi, NULL, "File information", "finfo"},
  -    {"parsed_uri",    (getter)getreq_recmbr, NULL, "Components of URI", "parsed_uri"},
  +    {"parsed_uri",    (getter)getreq_rec_uri, NULL, "Components of URI", "parsed_uri"},
       {"used_path_info", (getter)getreq_recmbr, NULL, "Flag to accept or reject path_info on current request", "used_path_info"},
       /* XXX per_dir_config */
       /* XXX request_config */
  
  
  
  1.10      +6 -5      httpd-python/src/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/util.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- util.c	12 Sep 2002 18:24:06 -0000	1.9
  +++ util.c	15 Sep 2002 23:45:35 -0000	1.10
  @@ -324,7 +324,7 @@
    *   Find an Apache module by name, used by get_addhandler_extensions
    */
   
  -module *find_module(char *name)
  +static module *find_module(char *name)
   {
       int n; 
       for (n = 0; ap_loaded_modules[n]; ++n) {
  @@ -401,14 +401,15 @@
    ** 
    *   Find a memberdef in a PyMemberDef array
    */
  -const PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name)
  +PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name)
   {
  -    PyMemberDef *md;
  +    const PyMemberDef *md;
   
       for (md = mlist; md->name != NULL; md++)
           if (strcmp(md->name, name) == 0)
  -            return md;
  +            return (PyMemberDef *)md;
   
       /* this should never happen or the mlist is screwed up */
       return NULL;
   }
  +
  
  
  
  1.7       +2 -2      httpd-python/src/include/util.h
  
  Index: util.h
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/include/util.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- util.h	12 Sep 2002 18:24:06 -0000	1.6
  +++ util.h	15 Sep 2002 23:45:35 -0000	1.7
  @@ -73,6 +73,6 @@
   PyObject *tuple_from_apr_uri(apr_uri_t *u);
   char * get_addhandler_extensions(request_rec *req);
   apr_status_t python_decref(void *object);
  -const PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name);
  +PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name);
   
   #endif /* !Mp_UTIL_H */