Roxen.git / server / base_server / module_support.pike

version» Context lines:

Roxen.git/server/base_server/module_support.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS. - // $Id: module_support.pike,v 1.149 2012/02/08 00:56:21 jonasw Exp $ + // $Id$      #define IN_ROXEN   #include <roxen.h>   #include <module_constants.h>   #include <stat.h>      protected int got_java_flag = 0; // 1: yes, -1: no, 0: unknown.      int got_java()   //! @appears roxen.got_java
Roxen.git/server/base_server/module_support.pike:330:    string get_compile_errors()    {    return ec?("<pre><font color='&usr.warncolor;'>"+    Roxen.html_encode_string( ec->get()+"\n"+    ec->get_warnings() ) +    "</font></pre>"):"";    }       array register_module()    { -  string locked_desc = +  string locked_desc = ""; +  +  if (sizeof(config_locked)) { +  locked_desc = "<p>" +    LOCALE(511," The module is locked and not part of the license. "    "To enable this module please select a valid license " -  "and restart the server."); +  "and restart the server.") + +  "</p>\n"; +  locked_desc += +  sprintf("<p>" + +  LOCALE(1092, "Required license feature: <tt>%s</tt>.") + +  "</p>\n", Roxen.html_encode_string(locked*":")); +  }    if (filename) {    return ({    0, // type    sprintf(LOCALE(350,"Load of %s (%s) failed"),    sname,filename),    sprintf(LOCALE(351,"The module %s (%s) could not be loaded."),    sname, get_name()||"unknown")+ -  (sizeof(config_locked)?locked_desc:"")+ +  locked_desc +    get_compile_errors(),0,0    });    } else {    return ({    0, // type    sprintf(LOCALE(357, "Load of %s failed: Module not found."), sname),    sprintf(LOCALE(351, "The module %s (%s) could not be loaded."),    sname, get_name()||"unknown")+ -  (sizeof(config_locked)?locked_desc:"")+ +  locked_desc +    get_compile_errors(),0,0    });    }    }       string _sprintf()    {    return sprintf("LoadFailed(%s)", sname);    }    }
Roxen.git/server/base_server/module_support.pike:557:    };    if (q)    if( stringp( q ) )    report_debug( q );    else    report_debug(describe_backtrace(q));    return 0;    }       -  protected constant nomods = (< "pike-modules", "CVS", ".svn", ".git" >); +  protected constant nomods = (< "pike-modules", "CVS", ".svn", ".git", +  "node_modules" >);       protected void rec_find_module_files (string what, string dir,    multiset(string) files)    {    if (r_file_stat(combine_path(dir, ".nomodules")) ||    r_file_stat(combine_path(dir, ".no_modules")))    return;    array dirlist = r_get_dir( dir );    if (!dirlist)    return;
Roxen.git/server/base_server/module_support.pike:587:    }       if( strlen( file ) < 3 )    continue;    if( (< '~','#' >)[file[-1]] )    continue;       if( strip_extention(file) == what )    {    -  if( (< "pike", "so", "jar", "class" >)[ extension( file ) ] ) +  if( (< "pike", "so" >)[ extension( file ) ] || +  ( (< "class", "jar" >)[extension(file)] && got_java()))    { -  +  // Skip inner classes in Java +  if (has_value(file, "$") && has_suffix(file, ".class")) +  continue; +     Stdio.File f = Stdio.File();    if( !f->open( fpath, "r" ) )    report_error ("Failed to open %s: %s\n",    fpath, strerror (f->errno()));    else if( (f->read( 4 ) != "#!NO" ) )    files[fpath] = 1;    }    }    }    }       int find_module( string sn )    { -  foreach( roxenp()->query( "ModuleDirs" ), string dir ) { +  foreach( roxenp()->query( "ModuleDirs" ) + roxenloader.package_module_path, +  string dir ) {    dir = roxen_path (dir);    multiset(string) files = (<>);    rec_find_module_files (sn, dir, files);    if (sizeof (files)) {    if (sizeof (files) > 1 &&    check_ambiguous_module (sn, indices (files)))    return 0;    else    return init_module (Multiset.Iterator (files)->index());    }
Roxen.git/server/base_server/module_support.pike:712:   }      mapping(string:ModuleInfo) modules;   protected void rec_find_all_modules( string dir,    mapping(string:string) modules )   {    Stdio.Stat s;    if (r_file_stat(combine_path(dir, ".nomodules")) ||    r_file_stat(combine_path(dir, ".no_modules")))    return; -  array(string) dirlist = (r_get_dir( dir ) || ({ }) ) - ({"CVS"}); +  array(string) dirlist = +  (r_get_dir( dir ) || ({ }) ) - ({ "CVS", ".git", "node_modules" });       foreach( dirlist, string file ) {    if( file[0] == '.' ) continue;    if( file[-1] == '~' ) continue;    string fpath = combine_path(dir, file);    if( (< "so", "pike">)[ extension( file ) ] ||    (<"class", "jar">)[extension (file)] && got_java())    { -  +  // Skip inner classes in Java +  if (has_value(file, "$") && has_suffix(file, ".class")) +  continue; +     Stdio.File f = Stdio.File();    if (!f->open( fpath, "r" ))    report_warning ("Failed to open %s: %s\n",    fpath, strerror (f->errno()));    else if( (f->read( 4 ) != "#!NO" ) )    modules[fpath] = strip_extention (file);    }    else if( (s = file_stat( fpath )) &&    s->isdir &&    (file != "pike-modules") &&
Roxen.git/server/base_server/module_support.pike:770:    report_debug("Searching for roxen modules ... \b");    t = gethrtime();    if( !modules )    {    modules = ([]);    module_cache = roxenp()->ConfigIFCache( "modules" );    }       array(string) possible = ({});    -  foreach( roxenp()->query( "ModuleDirs" ), string dir ) { +  foreach( roxenp()->query( "ModuleDirs" ) + roxenloader.package_module_path, +  string dir ) {    dir = roxen_path (dir);    mapping(string:string) module_files = ([]);    rec_find_all_modules( dir, module_files );       array(string) module_names = Array.uniq (values (module_files));    if (sizeof (module_names) < sizeof (module_files)) {    mapping(string:array(string)) inv = ([]);    foreach (module_files; string file; string name)    inv[name] += ({file});    foreach (inv; string name; array(string) files)
Roxen.git/server/base_server/module_support.pike:803:    report_debug("\bDone [%dms]\n", (gethrtime()-t)/1000 );       return all_modules_cache = tmp;   }         array(string) find_all_pike_module_directories()   {    if( all_pike_module_cache ) return all_pike_module_cache;    +  array skip_module_dirs = ({ "CVS", ".git", "node_modules" });    array(string) recurse( string dir )    {    Stdio.Stat st;    array res = ({}); -  foreach( get_dir( dir )||({}), string s ) +  foreach( (get_dir( dir ) || ({}) ) - skip_module_dirs, string s )    if( (st = file_stat( combine_path( dir, s ) )) && st->isdir )    if( s == "pike-modules" )    res += ({ dir+"/pike-modules" }); -  else if( s != "CVS" ) +  else    res += recurse( combine_path( dir, s ) );    return res;    };       all_pike_module_cache = ({}); -  foreach( roxenp()->query( "ModuleDirs" ), string dir ) +  foreach( roxenp()->query( "ModuleDirs" ) + roxenloader.package_module_path, +  string dir )    all_pike_module_cache += recurse( roxen_path (dir) );    return all_pike_module_cache;   }      // List of modules that have been renamed   protected constant module_aliases = ([    "whitespace_sucker":"whitespace_remover",   ]);      ModuleInfo find_module( string name, int|void noforce )