/[meteor]/googlecode.com/svn/trunk/Meteor/Config.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /googlecode.com/svn/trunk/Meteor/Config.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 44 by knops.gerd, Sun Feb 3 23:10:24 2008 UTC revision 45 by knops.gerd, Mon Feb 4 19:02:49 2008 UTC
# Line 63  package Meteor::Config; Line 63  package Meteor::Config;
63  'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values.  **NOTE**: It is possible to define more than one HeaderTemplate by appending a number at the end, for example *HeaderTemplate42*. Clients can request a specific header to be used by adding the parameter template=<number> to their GET request. If *HeaderTemplate<number>* is not found, the system will use the default HeaderTemplate (no number)',  'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values.  **NOTE**: It is possible to define more than one HeaderTemplate by appending a number at the end, for example *HeaderTemplate42*. Clients can request a specific header to be used by adding the parameter template=<number> to their GET request. If *HeaderTemplate<number>* is not found, the system will use the default HeaderTemplate (no number)',
64          HeaderTemplate                  => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta http-equiv="Cache-Control" content="no-store">\r\n<meta http-equiv="Cache-Control" content="no-cache">\r\n<meta http-equiv="Pragma" content="no-cache">\r\n<meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT">\r\n<script type="text/javascript">\r\nwindow.onError = null;\r\nvar domainparts = document.domain.split(".");\r\ndocument.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];\r\nparent.Meteor.register(this);\r\n</script>\r\n</head>\r\n<body onload="try { parent.Meteor.reset(this) } catch (e) {}">\r\n',          HeaderTemplate                  => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n<meta http-equiv="Cache-Control" content="no-store">\r\n<meta http-equiv="Cache-Control" content="no-cache">\r\n<meta http-equiv="Pragma" content="no-cache">\r\n<meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT">\r\n<script type="text/javascript">\r\nwindow.onError = null;\r\nvar domainparts = document.domain.split(".");\r\ndocument.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];\r\nparent.Meteor.register(this);\r\n</script>\r\n</head>\r\n<body onload="try { parent.Meteor.reset(this) } catch (e) {}">\r\n',
65    
66    'Template for each line in channelinfo',
67    
68            ChannelInfoTemplate             => '~name~ ~messageCount~\r\n',
69    
70  'Print out this help message',  'Print out this help message',
71          Help                                    => '',          Help                                    => '',
72    
# Line 84  package Meteor::Config; Line 88  package Meteor::Config;
88  'Interval at which PingMessage is sent to all persistent and identified subscriber connections (ie those including id=someuniqueidentifier in their request, and not specifying persist=0). Must be at least 3 if set higher than zero. Set to zero to disable.',  'Interval at which PingMessage is sent to all persistent and identified subscriber connections (ie those including id=someuniqueidentifier in their request, and not specifying persist=0). Must be at least 3 if set higher than zero. Set to zero to disable.',
89          PingInterval                    => 5,          PingInterval                    => 5,
90    
91    'Persistence of a connection. Note: some modes have this hardcoded!',
92    
93            Persist                                 => 0,
94    
95  'Message to be sent to all persistent and identified subscriber connections (see above) every PingInterval seconds',  'Message to be sent to all persistent and identified subscriber connections (see above) every PingInterval seconds',
96          PingMessage                             => '<script>p(-1,"");</script>\r\n',          PingMessage                             => '<script>p(-1,"");</script>\r\n',
97    
# Line 110  package Meteor::Config; Line 118  package Meteor::Config;
118          our %CommandLine=();          our %CommandLine=();
119          our %Defaults=();          our %Defaults=();
120          our %ExtraKeys=();          our %ExtraKeys=();
121            our %Modes=();
122                    
123          for(my $i=0;$i<scalar(@DEFAULTS);$i+=3)          for(my $i=0;$i<scalar(@DEFAULTS);$i+=3)
124          {          {
# Line 137  sub updateConfig { Line 146  sub updateConfig {
146          }          }
147          push(@keys,keys %ExtraKeys);          push(@keys,keys %ExtraKeys);
148                    
149          foreach my $key (@keys)          
150          {                        foreach my $mode ('',keys %Modes)
151                  if(exists($CommandLine{$key}))          {
152                  {                  foreach my $baseKey (@keys)
                         print STDERR "CmdLine" if($debug);  
                         $::CONF{$key}=$CommandLine{$key};  
                 }  
                 elsif(exists($ConfigFileData{$key}))  
                 {  
                         print STDERR "CnfFile" if($debug);  
                         $::CONF{$key}=$ConfigFileData{$key};  
                 }  
                 elsif(exists($Defaults{$key}))  
153                  {                  {
154                          print STDERR "Default" if($debug);                          my $foundValue=0;
155                          $::CONF{$key}=$Defaults{$key};                          my $key=$baseKey.$mode;
156                  }                          
157                                            if(exists($CommandLine{$key}))
                 print STDERR "\t$key\t$::CONF{$key}\n" if($debug);  
                   
                 # Take care of escapes  
                 $::CONF{$key}=~s/\\(.)/  
                         if($1 eq 'r')  
                         {  
                                 "\r";  
                         }  
                         elsif($1 eq 'n')  
                         {  
                                 "\n";  
                         }  
                         elsif($1 eq 's')  
158                          {                          {
159                                  ' ';                                  print STDERR "CmdLine" if($debug);
160                                    $::CONF{$key}=$CommandLine{$key};
161                                    $foundValue=1;
162                          }                          }
163                          elsif($1 eq 't')                          elsif(exists($ConfigFileData{$key}))
164                          {                          {
165                                  "\t";                                  print STDERR "CnfFile" if($debug);
166                                    $::CONF{$key}=$ConfigFileData{$key};
167                                    $foundValue=1;
168                          }                          }
169                          else                          elsif(exists($Defaults{$key}))
170                          {                          {
171                                  $1;                                  print STDERR "Default" if($debug);
172                                    $::CONF{$key}=$Defaults{$key};
173                                    $foundValue=1;
174                          }                          }
175                  /gex;                          
176                            next unless($foundValue);
177                            
178                            print STDERR "\t$key\t$::CONF{$key}\n" if($debug);
179                            
180                            # Take care of escapes
181                            $::CONF{$key}=~s/\\(.)/
182                                    if($1 eq 'r')
183                                    {
184                                            "\r";
185                                    }
186                                    elsif($1 eq 'n')
187                                    {
188                                            "\n";
189                                    }
190                                    elsif($1 eq 's')
191                                    {
192                                            ' ';
193                                    }
194                                    elsif($1 eq 't')
195                                    {
196                                            "\t";
197                                    }
198                                    else
199                                    {
200                                            $1;
201                                    }
202                            /gex;
203                    }
204          }          }
           
205          print STDERR '-'x79 ."\n" if($debug);          print STDERR '-'x79 ."\n" if($debug);
206  }  }
207    
# Line 218  sub setCommandLineParameters { Line 238  sub setCommandLineParameters {
238                                    
239                  $k='Debug' if($k eq 'd');                  $k='Debug' if($k eq 'd');
240                                    
241                    my $mode='';
242                    
243                    if($k=~s/(\..+)$//)
244                    {
245                            $mode=$1;
246                            $Modes{$mode}=1;
247                    }
248                    
249                  my $key=undef;                  my $key=undef;
250                  my $kl=length($k);                  my $kl=length($k);
251                  my $kOrig=$k;                  my $kOrig=$k;
# Line 262  sub setCommandLineParameters { Line 290  sub setCommandLineParameters {
290                                    
291                  #print "$kOrig: $key\n";                  #print "$kOrig: $key\n";
292                                    
293                  $CommandLine{$key}=1;                  $CommandLine{"$key$mode"}=1;
294                                    
295                  if($cnt>1 && $_[0]!~/^\-(?!\-)/)                  if($cnt>1 && $_[0]!~/^\-(?!\-)/)
296                  {                  {
297                          my $param=shift;                          my $param=shift;
298                          $param=~s/^\-\-/\-/;                          $param=~s/^\-\-/\-/;
299                          $CommandLine{$key}=$param;                          $CommandLine{"$key$mode"}=$param;
300                  }                  }
301          }          }
302                    
# Line 285  sub readConfig { Line 313  sub readConfig {
313          my $path=$class->valueForKey('ConfigFileLocation');          my $path=$class->valueForKey('ConfigFileLocation');
314          return unless(defined($path) && -f $path);          return unless(defined($path) && -f $path);
315                    
316            my $mode='';
317            
318          open(CONFIG,"$path") or &usage("Config file '$path' for read: $!\n");          open(CONFIG,"$path") or &usage("Config file '$path' for read: $!\n");
319          while(<CONFIG>)          while(<CONFIG>)
320          {          {
# Line 293  sub readConfig { Line 323  sub readConfig {
323                                    
324                  s/[\r\n]*$//;                  s/[\r\n]*$//;
325                                    
326                    if(/^\s*\[\s*([^\]\s]+)\s*\]\s*$/)
327                    {
328                            $Modes{".$1"}=1;
329                            next;
330                    }
331                    
332                  unless(/^(\S+)\s*(.*)/)                  unless(/^(\S+)\s*(.*)/)
333                  {                  {
334                          &usage("Invalid configuration file parameter line '$_'");                          &usage("Invalid configuration file parameter line '$_'");
# Line 310  sub readConfig { Line 346  sub readConfig {
346                  {                  {
347                          unless(exists($Defaults{$key}))                          unless(exists($Defaults{$key}))
348                          {                          {
349                                  &usage("Unknown configuration file parameter name '$key'");                                  &usage("Unknown configuration file parameter name '$key$mode'");
350                          }                          }
351                          if($key eq 'ConfigFileLocation')                          if($key eq 'ConfigFileLocation')
352                          {                          {
# Line 320  sub readConfig { Line 356  sub readConfig {
356                                    
357                  $val=~s/^--/-/;                  $val=~s/^--/-/;
358                                    
359                  $ConfigFileData{$key}=$val;                  $ConfigFileData{"$key$mode"}=$val;
360          }          }
361          close(CONFIG);          close(CONFIG);
362  }  }
# Line 340  EOT Line 376  EOT
376                    
377                  print STDERR <<"EOT";                  print STDERR <<"EOT";
378    
379  Meteor server v1.0 (release date: 1 Dec 2006)  Meteor server v$::VERSION (release date: $::RELEASE_DATE)
380  Licensed under the terms of the GNU General Public Licence (2.0)  Licensed under the terms of the GNU General Public Licence (2.0)
381    
382  Usage:  Usage:

Legend:
Removed from v.44  
changed lines
  Added in v.45

  ViewVC Help
Powered by ViewVC 1.1.26