Patches for ModRuby on Windows

Lothar Scholz <[email protected]>
Newsgroups gmane.comp.apache.mod-ruby
Organization Scriptolutions
Message-ID <[email protected]>
Hello ,

I' willing to spend some time to port mod_ruby to windows. I think
this is a step that many people want to see. But i need your help
because i've never written a C Ruby extension or an apache module. But
i know UNIX and WIN32 very well, working in both environments since
1992.

I tried to simply compile mod_ruby-1.1.2 with apache-2.0.48 under
Microsoft Visual and already found and fixed the following 3 errors.
Is it possible to check them into your CVS ?


Okay there are the fixes



============  1) File: apachelib.c  =======================

include <unistd.h> directive must be commented out for Windows it is
not necessary so please change line 30

#ifndef WIN32
#include <unistd.h>
#endif


===========  2)  File: apachelib.c  =========================

Here we have the typical windows problem of different function calling
conventions on the threads main function in line 675.

static void* APR_THREAD_FUNC ruby_thread_start(apr_thread_t *t, void *data)

Adding the APR_THREAD_FUNC declaration is necessary here.


============  3) File: request.c  =======================

Here the 'get_mode' function makes trouble. The mode_t type is not
defined under windows and can be substituted in a safe way with "int",
if it is not an int it will be convert in exactly the same way
because it is not used for a storage place. Also some of the file
modes are unkown in windows.


#ifdef APACHE2
static int get_mode(apr_finfo_t *finfo)
{
    int mode = 0;

    if (finfo->protection & APR_UREAD)
        mode |= S_IRUSR;
    if (finfo->protection & APR_UWRITE)
        mode |= S_IWUSR;
    if (finfo->protection & APR_UEXECUTE)
        mode |= S_IXUSR;

    if (finfo->protection & APR_GREAD)
        mode |= S_IRGRP;
    if (finfo->protection & APR_GWRITE)
        mode |= S_IWGRP;
    if (finfo->protection & APR_GEXECUTE)
        mode |= S_IXGRP;

    if (finfo->protection & APR_WREAD)
        mode |= S_IROTH;
    if (finfo->protection & APR_WWRITE)
        mode |= S_IWOTH;
    if (finfo->protection & APR_WEXECUTE)
        mode |= S_IXOTH;

    switch (finfo->filetype) {
    case APR_REG:
        mode |= S_IFREG;
        break;
    case APR_DIR:
        mode |= S_IFDIR;
        break;
    case APR_CHR:
        mode |= S_IFCHR;
        break;
    case APR_BLK:
#ifndef WIN32
        mode |= S_IFBLK;
#endif
        break;
    case APR_PIPE:
#ifndef WIN32    
        mode |= S_IFIFO;
#endif  
        break;
    case APR_LNK:
#ifndef WIN32   
        mode |= S_IFLNK;
#endif  
        break;
    case APR_SOCK:
#if !defined(BEOS) && defined(S_ISSOCK)
        mode |= S_IFSOCK;
#endif
        break;
    default:
        break;
    }

    return mode;
}
#endif /* APACHE2 */
======================================================================


This is what i could do until now. But i need some more information
how mod_ruby is working. Can you please explaing what preprocessor
declaration you use. I compile with

cl -c  -DAPR_HAS_THREADS -DWIN32 -DNDEBUG -DWINDOWS  $(APACHE_INC_DIR) -I$(RUBY_DIR)

where APACHE_INC_DIR is defined as

-I$(APACHE_DIR)\include -I$(APACHE_DIR)\srclib\apr\include -I$(APACHE_DIR)\srclib\apr-util\include -I$(APACHE_DIR)\os\win32

But it seems that i must have HAVE_LIBAPREQ also defined. What is this
for a library ? I can't find a "apache_request.h" file in the apache
distribution. Otherwise "upload.c" and "cookie.c" can't compile.


Thank you very much,


-- 
Best regards,
 Lothar                          mailto:[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.